← iOS Development (Swift) learning pathiOS Development (Swift) · Module 8 of 10
Networking and async/await
Fetch data from APIs with modern concurrency.
📖 Key ideas
- URLSession.shared.data(from: url) with async/await.
- Decode JSON with JSONDecoder into Codable structs.
- Use .task { } in SwiftUI to load data when a view appears.
- Mark UI updates on @MainActor.
- Handle errors and show loading states.
💡 Real-life example: async/await is ordering at a counter and getting a buzzer, without blocking the queue.
URLSessionNetworking API
JSONDecoderDecodes JSON into types
async/awaitModern concurrency syntax
@MainActorRuns code on the main thread