By default, iOS URL Loading System supports the following schemes:
- _ftp:// _for File Transfer Protocol
- _http:// _for Hypertext Transfer Protocol
- _https:// _for Hypertext Transfer Protocol with encryption
- _file:// _for local file URLs
- _data:// _for data URLs
URL Loading System
Desc
A set of classes known as theURL Loading System, handles URL requests. You need to know them to find out how iOS handles your app’s requests to load a URL-based resource.
Mechnism
At the heart of the URL Loading System is theNSURL
class. For network requests, this class tells what host your app is trying to reach and path to the resource at that host. In addition theNSURLRequest
object adds information like HTTP headers, the body of your message, etc.. The loading system provides a few different classes you can use to process the request, the most common beingNSURLConnection
andNSURLSession
.
When you receive a response it comes back in two parts: metadata and data. The metadata is encapsulated in aNSURLResponse
object. It will tell you the MIME type, the text encoding (when applicable), the expected amount of data of your response and the URL that is the source of the information. The data arrives asNSData
objects.
Behind the scenes, when the loading system downloads information using aNSURLRequest
, it will create an instance of aNSURLProtocol
subclass, which represents your custom URL protocol.NSURLProtocol
is an abstract class that exists only to be extended in this way. You should never instantiate anNSURLProtocol
object directly.