[ad_1]
In a separate knowledge file known as knowledge.swift I’ve this code
struct Response: Decodable {
var knowledge: Information
}
struct Information: Decodable {
var search: search
}
struct search: Decodable {
var __Typename: String
var question: String
var searchResults: searchResults
}
…and so forth and so forth. I then decode the info from a Speedy-Api like so
let session = URLSession.shared
let dataTask = session.dataTask(with: request as URLRequest, completionHandler: { (knowledge, response, error) -> Void in
if (error != nil) {
print(error!)
} else {
let merchandise = attempt? JSONSerialization.jsonObject(with: knowledge!, choices: .allowFragments)
if let water = merchandise {
print("JSON: n" + String(describing: water) + "n")
}
}
})
How do I show the info components in ProductList.swift it is a (view) file. The API works as anticipated and shows the JSON within the terminal. I’m utilizing XCODE 12.4 as I’m not permitted to improve any additional.
[ad_2]
