Initializes an NSURL object with a provided URL string.
SDKs
- iOS 2.0+
- macOS 10.0+
- Mac Catalyst 13.0+
- tvOS 9.0+
- watchOS 2.0+
Framework
- Foundation
Declaration
- (instancetype)initWithString:(NSString *)URLString;
Parameters
URLString
The URL string with which to initialize the NSURL object. This URL string must conform to URL format as described in RFC 2396, and must not be
nil
. This method parsesURLString
according to RFCs 1738 and 1808.
Return Value
An NSURL object initialized with URLString
. If the URL string was malformed, returns nil
.
Discussion
This method expects URLString
to contain only characters that are allowed in a properly formed URL. All other characters must be properly percent escaped. Any percent-escaped characters are interpreted using UTF-8 encoding.