NSURL is a class from Foundation.framework in Apple MacOS and iOS. The NSURL class provides the ability to manipulate URLs and the resources they refer to. An NSURL object represents a URL that can potentially contain the location of a resource on a remote server, the path of a local file on disk, or even an arbitrary piece of encoded data. It is available in iOS 2.0 and later
The NSURL class provides a way to manipulate URLs and the resources they reference. NSURL objects understand URLs as specified in RFCs 1808, 1738, and 2732. The litmus test for conformance to RFC 1808 is as recommended in RFC 1808—whether the first two characters of resourceSpecifier are slashes (//).
An NSURL object is composed of two parts — a potentially nil base URL and a string that is resolved relative to the base URL. An NSURL object whose string is fully resolved without a base is considered absolute; all others are considered relative.
The NSURL class fails to create a new NSURL object if the path being passed is not well-formed; the path must comply with RFC 2396.
The NSURL class is toll-free bridged with its Core Foundation counterpart, CFURLRef.
Sample:
For example, when constructing an NSURL object, you might specify file:///path/to/web_root/ as the base URL and folder/file.html as the string part, as follows:
NSURL *baseURL = [NSURL URLWithString:@"file:///path/to/web_root/"];
NSURL *url = [NSURL URLWithString:@"folder/file.html" relativeToURL:baseURL];
NSURL *absURL = [url absoluteURL];
NSLog(@"absURL = %@", absURL);