NSURLComponents
An object that parses URLs into and constructs URLs from their constituent parts.
Declaration
class NSURLComponentsOverview
In Swift, this object bridges to URLComponents; use NSURLComponents when you need reference semantics or other Foundation-specific behavior.
The NSURLComponents class is a class that is designed to parse URLs based on RFC 3986 and to construct URLs from their constituent parts. Its behavior differs subtly from the NSURL class, which conforms to older RFCs. However, you can easily obtain an NSURL object based on the contents of a URL components object or vice versa.
You create a URL components object in one of three ways: from an NSString object that contains a URL, from an NSURL object, or from scratch by using the default initializer. From there, you can modify the URL’s individual components and subcomponents by modifying various properties, either in unencoded form or in URL-encoded form. If you set the unencoded property, you can then obtain the encoded equivalent by reading the encoded property value and vice versa.
Topics
Creating URL components
Getting the URL
Accessing components in native format
Accessing components in URL-encoded format
percentEncodedFragmentpercentEncodedHostpercentEncodedPasswordpercentEncodedPathpercentEncodedQuerypercentEncodedUser
Locating components in the URL string representation
percentEncodedQueryItemsrangeOfFragmentrangeOfHostrangeOfPasswordrangeOfPathrangeOfPortrangeOfQueryrangeOfSchemerangeOfUser