The document discusses URLProtocol and the URL loading system in iOS. It provides an overview of the URL loading system and describes how URLProtocol allows handling loading of protocol-specific URL data. It then demonstrates implementing a custom URLProtocol subclass to intercept and handle requests, including returning mock data or errors. It also discusses using URLProtocol with URLSession by registering custom protocol classes.
8. URL Loading System
The URL loading system is a set of classes and
protocols that allow your app to access content
referenced by a URL. At the heart of this
technology is the NSURL class, which lets your
app manipulate URLs and the resources they
refer to.
https://developer.apple.com/library/content/documentation/Cocoa/Conceptual/
URLLoadingSystem/URLLoadingSystem.html
14. URLProtocol
An NSURLProtocol object handles the loading
of protocol-specific URL data. The
NSURLProtocol class itself is an abstract class
that provides the infrastructure for processing
URLs with a specific URL scheme. You create
subclasses for any custom protocols or URL
schemes that your app supports.
https://developer.apple.com/documentation/foundation/urlprotocol
38. URLSession.shared
• The shared session uses the shared NSURLCache,
NSHTTPCookieStorage, and NSURLCredentialStorage
objects, uses a shared custom networking protocol list
(configured with registerClass(_:) and unregisterClass(_:)),
and is based on a default configuration.
• In other words, if you’re doing anything with caches,
cookies, authentication, or custom networking protocols,
you should probably be using a default session instead of
the shared session.
https://developer.apple.com/documentation/foundation/urlsession/1409000-shared