0Pricing
Swift Academy · Lesson

Networking with Combine and URLSession

Using URLSession.dataTaskPublisher with Combine to handle network responses.

Welcome

URLSession has built-in Combine support via `dataTaskPublisher`. Combined with `decode`, it makes type-safe networking pipelines in just a few lines.

dataTaskPublisher

```swift URLSession.shared .dataTaskPublisher(for: URL(string:"https://api.example.com/users")!) .sink(receiveCompletion: { print($0) }, receiveValue: { data, response in print(data.count) }) .store(in: &cancellables) ```

All lessons in this course

  1. Publishers and Subscribers
  2. Operators: map, filter, combineLatest
  3. PassthroughSubject and CurrentValueSubject
  4. Networking with Combine and URLSession
← Back to Swift Academy