← iOS Development (Swift) learning path
iOS Development (Swift) · Module 8 of 10

Networking and async/await

Fetch data from APIs with modern concurrency.

📖 Key ideas

  1. URLSession.shared.data(from: url) with async/await.
  2. Decode JSON with JSONDecoder into Codable structs.
  3. Use .task { } in SwiftUI to load data when a view appears.
  4. Mark UI updates on @MainActor.
  5. 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