Skip to content

Initializer

init(dataRepresentation:relativeTo:isAbsolute:)

iOS 9.0+ iPadOS 9.0+ Mac Catalyst 9.0+ macOS 10.11+ tvOS 9.0+ watchOS 2.0+
Initializes a newly created URL using the contents of the given data, relative to a base URL.
init?(dataRepresentation: Data, relativeTo base: URL?, isAbsolute: Bool = false)

Discussion

If the data representation isn’t a legal URL string as ASCII bytes, the URL object may not behave as expected. This initializer returns nil if it can’t form a valid URL from the provided data.