我的NSURL是向后格式化的,即使在从其他项目复制和粘贴代码时也是如此。
例如:
let baseURL = NSURL(string: "http://example.com/v1/")
NSURL(string: "foo", relativeToURL: baseURL)应返回:"http://example.com/v1/foo“
相反,返回:"foo -- ttp://example.com/v1/“
有人见过这个吗?
发布于 2016-05-06 07:17:03
这就是相对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"https://stackoverflow.com/questions/37066394
复制相似问题