[swift-users] NSURLComponents - setting scheme bug?

Michal Kalinowski michal.kalinowski at icloud.com
Wed May 25 15:56:04 CDT 2016

Hello all,

I have just discovered following behaviour of NSURLComponents and I'm looking for confirmation if it is in fact a bug.

var components = NSURLComponents(string: "apple.com")!
components.scheme = "http"
print(components.scheme)                            // prints "Optional("http")\n"
print(components.URL?.absoluteURL)                  // prints ""Optional(http:apple.com)\n", I'd expect http://apple.com

When trying to set scheme as "http://" I get an error which is in line with what documentation says. So it seems there is no way of setting the scheme after URLComponents initialisation and getting correct URL as a result.

Any thoughts?
Michał Kalinowski
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.swift.org/pipermail/swift-users/attachments/20160525/287f3177/attachment.html>

More information about the swift-users mailing list