TEAM LICENSES: Save money and learn new skills through a Hacking with Swift+ team license >>

Sending and receiving Codable data with URLSession and SwiftUI

Forums > Swift

I have spent all day on this and I think I have narrowed it down to the decoder not working. I ended up copying the video tutorial line for line and no data populates. I've tried many variations and I cannot get the decoder to work at all.

This line seems not to catch decoding issues:

if let decodedResponse = try? JSONDecoder().decode(Response.self, from: data) {
                results = decodedResponse.results

My output and simulator are completely blank. Again, the code is exactly the same as the tutorial day 49 2nd video. Pretty discouraging from a tutorial since getting data is essential for any meaningful app. XCode version: 15.3

   

Open a new browser window.

Copy the URL from your code and paste it into the browser window. Do you get a screen full of json data from Apple?

   

Hacking with Swift is sponsored by Blaze.

SPONSORED Still waiting on your CI build? Speed it up ~3x with Blaze - change one line, pay less, keep your existing GitHub workflows. First 25 HWS readers to use code HACKING at checkout get 50% off the first year. Try it now for free!

Reserve your spot now

Sponsor Hacking with Swift and reach the world's largest Swift community!

Reply to this topic…

You need to create an account or log in to reply.

All interactions here are governed by our code of conduct.

 
Unknown user

You are not logged in

Log in or create account
 

Link copied to your pasteboard.