我的NSURL被向后格式化,即使在复制和粘贴其他项目的代码时也是如此,这毫无意义。
例如:
let baseURL = NSURL(string: "http://example.com/v1/")
NSURL(string: "foo", relativeToURL: baseURL)
应返回:"http://example.com/v1/foo"
而是返回:"foo--ttp://example.com/v1/"
以前有人见过这个吗?
这就是相对URL在其(调试)描述中的显示方式。absoluteString
仍然是正确的;这种格式是不相关的。
let baseURL = NSURL(string: "http://example.com/v1/")!
let u = NSURL(string: "foo", relativeToURL: baseURL)!
print(u) // prints the URL's description, "foo -- http://example.com/v1/"
print(u.absoluteString) // prints "http://example.com/v1/foo"