init(string:encodingInvalidCharacters:)
Creates an instance from the provided string, optionally IDNA- and percent-encoding any invalid characters.
Declaration
convenience init?(string URLString: String, encodingInvalidCharacters: Bool)Parameters
- URLString:
A URL location.
- encodingInvalidCharacters:
A Boolean value that indicates whether the initializer attempts to encode any invalid characters in
string.
Discussion
If encodingInvalidCharacters is true, this initializer tries to encode the string to create a valid URL. If the URL string is still invalid after encoding, the initializer returns nil.
See Also
Creating a URL object
init(string:)init(string:relativeTo:)fileURL(withPath:isDirectory:)init(fileURLWithPath:isDirectory:)fileURL(withPath:relativeTo:)init(fileURLWithPath:relativeTo:)fileURL(withPath:isDirectory:relativeTo:)init(fileURLWithPath:isDirectory:relativeTo:)fileURL(withPath:)init(fileURLWithPath:)fileURL(withPathComponents:)init(resolvingAliasFileAt:options:)init(resolvingBookmarkData:options:relativeTo:bookmarkDataIsStale:)fileURL(withFileSystemRepresentation:isDirectory:relativeTo:)getFileSystemRepresentation(_:maxLength:)