Saturday, November 21, 2026
HomeiOS Developmentios - Swift - How do I present Information in Swift View...

ios – Swift – How do I present Information in Swift View from Information.swift file?

[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]

RELATED ARTICLES

LEAVE A REPLY

Please enter your comment!
Please enter your name here

Most Popular

Recent Comments