You are right Jens. If I use `appendingPathComponent`, it works.
let url = URL(fileURLWithPath: "foo/bar", isDirectory: false)
let baseURL = url.deletingLastPathComponent()
let newURL = URL(fileURLWithPath: "bar", isDirectory: false, relativeTo:
let testURL = baseURL.appendingPathComponent("bar")
print(url == newURL) // prints false
print(url.path == newURL.path) // prints true
print(url == testURL) // prints true
print(url.path == testURL.path) // prints true
On Sat, Oct 15, 2016 at 11:19 AM, Jens Alfke <email@example.com> wrote:
> On Oct 14, 2016, at 5:16 PM, zh ao via swift-users < > firstname.lastname@example.org> wrote:
> In your opinion, `baseURL` is a factor more important than `path`. I can
not unaccept your answer. But I want to know why? Is there a standard on
I think this is just a weirdness of NSURL (assuming you’re running this
code on macOS or iOS.) I’ve always avoided the `relativeTo:` initializers
of NSURL because the objects they produce behave (IMHO) unexpectedly.