This file has been truncated, but you can view the full file.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[ | |
{"country":"UA","name":"Hurzuf","_id":707860,"coord":{"lon":34.283333,"lat":44.549999}}, | |
{"country":"RU","name":"Novinki","_id":519188,"coord":{"lon":37.666668,"lat":55.683334}}, | |
{"country":"NP","name":"Gorkhā","_id":1283378,"coord":{"lon":84.633331,"lat":28}}, | |
{"country":"IN","name":"State of Haryāna","_id":1270260,"coord":{"lon":76,"lat":29}}, | |
{"country":"UA","name":"Holubynka","_id":708546,"coord":{"lon":33.900002,"lat":44.599998}}, | |
{"country":"NP","name":"Bāgmatī Zone","_id":1283710,"coord":{"lon":85.416664,"lat":28}}, | |
{"country":"RU","name":"Mar’ina Roshcha","_id":529334,"coord":{"lon":37.611111,"lat":55.796391}}, | |
{"country":"IN","name":"Republic of India","_id":1269750,"coord":{"lon":77,"lat":20}}, |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{"items":[{"browser":{"onLine":true,"product":"Gecko","appCodeName":"Mozilla","userAgent":"Mozilla\/5.0 (Macintosh; Intel Mac OS X 10_8_5) AppleWebKit\/537.36 (KHTML, like Gecko) Chrome\/32.0.1700.102 Safari\/537.36","platform":"MacIntel","appVersion":"5.0 (Macintosh; Intel Mac OS X 10_8_5) AppleWebKit\/537.36 (KHTML, like Gecko) Chrome\/32.0.1700.102 Safari\/537.36","appName":"Netscape","vendorSub":"","vendor":"Google Inc.","productSub":"20030107","cookieEnabled":true,"language":"fr"},"campaign":[],"comment":"belle offre de services","computed_browser":{"Browser":"Chrome","Version":"32.0","Platform":"MacOSX","FullBrowser":"Chrome"},"computed_location":"France","creation_date":1391445344,"custom":{"subject":"compliment"},"email":"[email protected]","geo":{"country":"FR","region":"A8","city":"Paris","lat":48.8667,"lon":2.3333},"host":"https:\/\/sample.com","html_snippet":null,"images":{"screenshot":{"uri":"52efc552b6679cfe6ede406c\/screenshot","width":1583,"height":1835,"url":"\/\/sample-feedback-live.s3.amaz |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public init(..., content: @ViewBuilder () -> Content) | |
//Note: The official docs won't show the attribute. | |
//But you can simply check this by assigning the value of VStack(){} to a variable and check variable type | |
//The Variable type will be TupleView<(Text, Text)> | |
//And TupleView is returned ViewBuilder.buildBlock function |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Original source code: | |
@TupleBuilder | |
func build() -> (String, String, Int) { | |
"a" | |
"b" | |
1 | |
} | |
// This code is interpreted exactly as if it were this code: | |
func build() -> (String, String, Int) { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public init(alignment: HorizontalAlignment = .center, | |
spacing: Length? = nil, | |
content: () -> Content) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@available(iOS 13.0, OSX 10.15, tvOS 13.0, watchOS 6.0, *) | |
public protocol View : _View { | |
/// The type of view representing the body of this view. | |
/// | |
/// When you create a custom view, Swift infers this type from your | |
/// implementation of the required `body` property. | |
associatedtype Body : View | |
/// Declares the content and behavior of this view. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import SwiftUI | |
import PlaygroundSupport | |
struct ContainerView: View { | |
var body: some View { | |
VStack() { | |
Text ("Hello World") | |
.font(.title) | |
.color(.blue) | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
let myStruct = try JSONDecoder().decode(Content.self, from: json) // decoding our data | |
myStruct.body.forEach { bodyContent in | |
let value: String? = bodyContent.content?.getContent() | |
let intValue: Int? = bodyContent.content?.getContent() | |
let finalValue = value ?? intValue.map(String.init) ?? "NA" | |
print("Data for type: \(bodyContent.type) is Data: \(finalValue)") | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
struct Content: Decodable { | |
var body: [Body] | |
} | |
protocol BodyContent: Decodable { | |
func getContent<T: Decodable>() -> T? | |
} | |
struct Body: Decodable { | |
var type: String |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// json is a variable holding a JSON Data value | |
let myStruct = try JSONDecoder().decode(Content.self, from: json) // decoding our data | |
myStruct.body.forEach { (value: BodyContent) in | |
switch value { | |
case .number(let number): | |
print("Data for type: number is Data: \(number)") | |
case .text(let string): | |
print("Data for type: string is Data: \(string)") | |
case .unsupported: | |
print("Type not supported") |
NewerOlder