URLSession is used in iOS to perform network requests.
It allows apps to:
send requests to a server
receive responses
handle data asynchronously
Core flow:
URL → URLSession → URLSessionTask → Response
Represents the endpoint:
let url = URL(string: "<https://jsonplaceholder.typicode.com/todos/1>")
Manages network requests:
let session = URLSession.shared
This is the default shared session.
Represents the actual request:
let task = session.dataTask(with: url) { data, response, error in
// handle response
}