I’ve this code:
import SwiftUI
struct Response: Codable {
var outcomes: [Result]
}
struct Consequence: Codable {
var trackId: String
var trackName: String
var collectionName: String
}
struct ContentView: View {
@State personal var outcomes = [Result]()
var physique: some View {
Record(outcomes, id: .trackId) { merchandise in
VStack(alignment: .main, content material: {
Textual content(merchandise.trackName)
.font(.headline)
Textual content(merchandise.collectionName)
})
}
.process {
await loadData()
}
}
func loadData() async {
guard let url = URL(string: "https://itunes.apple.com/search?time period=taylor+swift&entity=music") else {
print("Invalid URL")
return
}
do {
let (knowledge, _) = strive await URLSession.shared.knowledge(from: url)
if let decodedResponse = strive? JSONDecoder().decode(Response.self, from: knowledge) {
outcomes = decodedResponse.outcomes
}
} catch {
print("Invalid knowledge")
}
}
}
is coming from an instance from Paul Hudson’s course 100DaysOfSwiftUI, Day 49. The teachings are proper now up to date by him for iOS 17, however Day 49 is not up to date but.
I attempted to run the code however I get clean display, sadly Xcode would not generate errors or something for it, so I wasn’t capable of determine the place this code fails.
Any concepts?
for references:
right here is the web page the place the instance is coming from https://www.hackingwithswift.com/books/ios-swiftui/sending-and-receiving-codable-data-with-urlsession-and-swiftui