A structure that parses URLs into and constructs URLs from their constituent parts.
SDKs
- iOS 7.0+
- macOS 10.9+
- tvOS 9.0+
- watchOS 2.0+
- Xcode 8.0+
Framework
- Foundation
A structure that parses URLs into and constructs URLs from their constituent parts.
SDKs
Framework
init()
Initializes with all components undefined.
var url: URL?
A URL created from the components.
func url(relative To: URL?) -> URL?
Returns a URL based on the component settings and relative to a given base URL.
var string: String?
A URL derived from the components object, in string form.
var fragment: String?
The fragment subcomponent.
var host: String?
The host subcomponent.
var password: String?
The password subcomponent of the URL.
var path: String
The path subcomponent.
var port: Int?
The port subcomponent.
var query: String?
The query subcomponent.
var query Items: [URLQuery Item]?
An array of query items for the URL in the order in which they appear in the original query string.
var scheme: String?
The scheme subcomponent of the URL.
var user: String?
The user subcomponent of the URL.
var percent Encoded Fragment: String?
The fragment subcomponent, percent-encoded.
var percent Encoded Host: String?
The host subcomponent, percent-encoded.
var percent Encoded Password: String?
The password subcomponent, percent-encoded.
var percent Encoded Path: String
The path subcomponent, percent-encoded.
var percent Encoded Query: String?
The query subcomponent, percent-encoded.
var percent Encoded User: String?
The user subcomponent, percent-encoded.
var range Of Fragment: Range<String .Index>?
Returns the character range of the fragment in the string returned by the string property.
var range Of Host: Range<String .Index>?
Returns the character range of the host in the string returned by the string property.
var range Of Password: Range<String .Index>?
Returns the character range of the password in the string returned by the string property.
var range Of Path: Range<String .Index>?
Returns the character range of the path in the string returned by the string property.
var range Of Port: Range<String .Index>?
Returns the character range of the port in the string returned by the string property.
var range Of Query: Range<String .Index>?
Returns the character range of the query in the string returned by the string property.
var range Of Scheme: Range<String .Index>?
Returns the character range of the scheme in the string returned by the string property.
var range Of User: Range<String .Index>?
Returns the character range of the user in the string returned by the string property.
static func != (URLComponents, URLComponents) -> Bool
Returns a Boolean value indicating whether two values are not equal.
static func == (URLComponents, URLComponents) -> Bool
Indicates whether two URL component instances are the same.
var description: String
A textual description of the URL components.
var debug Description: String
A textual description of the URL components suitable for debugging.
var custom Mirror: Mirror
A mirror that reflects the URL components.
var hash Value: Int
The computed hash value for the URL components.
class NSURLComponents
An object that parses URLs into and constructs URLs from their constituent parts that bridges to URLComponents
; use NSURLComponents
when you need reference semantics or other Foundation-specific behavior.
typealias URLComponents .Reference Type
An alias for this value type's equivalent reference type.
struct URL
A value that identifies the location of a resource, such as an item on a remote server or the path to a local file.
struct URLQuery Item
A single name-value pair from the query portion of a URL.