
上QQ阅读APP看书,第一时间看更新
HTTP with URLSession
URLSession is a class that manages tasks related to network data transfers. You use URLSession when you want to download or upload data to an HTTP server.
Combined with Codable types, URLSession provides a very convenient abstraction over your network requests, if you're using a JSON-based API, for example. In this section, we'll look at how we can use Encodable and Decodable to represent request and responses bodies in a generic and compile time-safe manner.