This guide describes the Foundation framework classes available for interacting with URLs and communicating with servers using standard Internet protocols. Together these classes are referred to as the URL loading system.
The NSURL class provides the ability to manipulate URLs and the resources they refer to.
The Foundation framework also provides a rich collection of classes that include support for URL loading, cookie storage, response caching, credential storage and authentication, and writing custom protocol extensions.
The URL loading system provides support for accessing resources using the following protocols:
File Transfer Protocol (ftp://
)
Hypertext Transfer Protocol (http://
)
Secure 128-bit Hypertext Transfer Protocol (https://
)
Local file URLs (file:///
)
It also transparently supports both proxy servers and SOCKS gateways using the user’s system preferences.
This guide includes the following articles:
“URL Loading System Overview” describes the classes of the URL loading system and their interaction.
“Using NSURLConnection” describes using NSURLConnection for asynchronous connections.
“Using NSURLDownload” describes using NSURLDownload to download files asynchronously to disk.
“Handling Redirects and Other Request Changes” describes the options you have for responding to a change to your URL request.
“Authentication Challenges” describes the process for authenticating your connection against a secure server.
“Understanding Cache Access” describes how a connection uses the cache during a request.
The following sample code is available through Apple Developer Connection:
SpecialPictureProtocol implements a custom NSURLProtocol
that creates jpeg images in memory as data is downloaded.
AutoUpdater demonstrates how to check for, and download, an application update using NSURLConnection
and NSURLDownload
.
Last updated: 2010-03-24