3 objects NSMutableURLRequest, URLSession, and URLSessionDataTask to get data from a server. Like other managers we’ve used, they’re just subclasses of NSObject but with extra properties and methods to facilitate interactive with a remote server.
powerful, are missing features that a full-fledged, network-based application may need. Many companies and indie developers use the AFNetworking 3rd-party library which uses these objects under the hood.
away the hard parts. Things like locking to avoid race conditions. Inside the network block, we wrap ‘layoutMapWithData’ so that it’s executed on the main thread.
are asking the system’s runtime to asynchronously run some process on the main thread. We want it done asynchronously so that it occurs without interfering with the current process (in this case downloading from a webservice). Under the hood, this DispatchQueue is done serially - the code in the block is performed in order and not at the same time.
the call to DispatchQueue.main.async in layoutMapWithDictionary? Try it and you’ll find that the map is no longer annotated with pins. (Jerk the map a little and the pins appear because MapKit reloads with a full datasource).