nazaniel nazaniel - 5 months ago 8x
Swift Question

NSURL relativeToURL backwards?

My NSURLs are being formatted backwards, even when copying and pasting in code from other projects which makes zero sense.

For example:

let baseURL = NSURL(string: "")
NSURL(string: "foo", relativeToURL: baseURL)

Should return: ""

Instead returns: "foo -- ttp://"

Has anyone seen this before?


That's simply how relative URLs are displayed in their (debug) description. The absoluteString will still be correct; this format is unrelated.

let baseURL = NSURL(string: "")!
let u = NSURL(string: "foo", relativeToURL: baseURL)!

print(u)  // prints the URL's description, "foo --"
print(u.absoluteString)  // prints ""