What's the difference between passing false and true to 'resolvingAgainstBaseURL' when initialize a NSURLComponents instance?
It makes only a difference if you create the URL components from an NSURL
which was created relative to another NSURL
:
let baseURL = NSURL(string: "http://server/foo/")!let url = NSURL(string: "bar/file.html", relativeToURL: baseURL)!print(url.absoluteString)// "http://server/foo/bar/file.html"
With resolvingAgainstBaseURL == false
, the URL componentsrepresent only the relative part of the URL:
let comp1 = NSURLComponents(URL: url, resolvingAgainstBaseURL: false)!print(comp1.string!)// "bar/file.html"
With resolvingAgainstBaseURL == true
, the URL componentsrepresent the fully resolved URL:
let comp2 = NSURLComponents(URL: url, resolvingAgainstBaseURL: true)!print(comp2.string!)// "http://server/foo/bar/file.html"