<div dir="ltr"><div class="gmail_default" style="font-family:georgia,serif">You are right Jens. If I use `appendingPathComponent`, it works.</div><div class="gmail_default" style="font-family:georgia,serif"><br></div><div class="gmail_default" style="font-family:georgia,serif"><p style="margin:0px;font-size:11px;line-height:normal;font-family:menlo;color:rgb(0,0,0)"><span style="font-variant-ligatures:no-common-ligatures;color:rgb(186,45,162)">let</span><span style="font-variant-ligatures:no-common-ligatures"> url = </span><span style="font-variant-ligatures:no-common-ligatures;color:rgb(112,61,170)">URL</span><span style="font-variant-ligatures:no-common-ligatures">(fileURLWithPath: </span><span style="font-variant-ligatures:no-common-ligatures;color:rgb(209,47,27)">"foo/bar"</span><span style="font-variant-ligatures:no-common-ligatures">, isDirectory: </span><span style="font-variant-ligatures:no-common-ligatures;color:rgb(186,45,162)">false</span><span style="font-variant-ligatures:no-common-ligatures">)</span></p>
<p style="margin:0px;font-size:11px;line-height:normal;font-family:menlo;color:rgb(62,30,129)"><span style="font-variant-ligatures:no-common-ligatures;color:rgb(186,45,162)">let</span><span style="font-variant-ligatures:no-common-ligatures;color:rgb(0,0,0)"> baseURL = </span><span style="font-variant-ligatures:no-common-ligatures;color:rgb(79,129,135)">url</span><span style="font-variant-ligatures:no-common-ligatures;color:rgb(0,0,0)">.</span><span style="font-variant-ligatures:no-common-ligatures">deletingLastPathComponent</span><span style="font-variant-ligatures:no-common-ligatures;color:rgb(0,0,0)">()</span></p>
<p style="margin:0px;font-size:11px;line-height:normal;font-family:menlo;color:rgb(0,0,0)"><span style="font-variant-ligatures:no-common-ligatures;color:rgb(186,45,162)">let</span><span style="font-variant-ligatures:no-common-ligatures"> newURL = </span><span style="font-variant-ligatures:no-common-ligatures;color:rgb(112,61,170)">URL</span><span style="font-variant-ligatures:no-common-ligatures">(fileURLWithPath: </span><span style="font-variant-ligatures:no-common-ligatures;color:rgb(209,47,27)">"bar"</span><span style="font-variant-ligatures:no-common-ligatures">, isDirectory: </span><span style="font-variant-ligatures:no-common-ligatures;color:rgb(186,45,162)">false</span><span style="font-variant-ligatures:no-common-ligatures">, relativeTo: </span><span style="font-variant-ligatures:no-common-ligatures;color:rgb(79,129,135)">baseURL</span><span style="font-variant-ligatures:no-common-ligatures">)</span></p>
<p style="margin:0px;font-size:11px;line-height:normal;font-family:menlo;color:rgb(62,30,129)"><span style="font-variant-ligatures:no-common-ligatures;color:rgb(186,45,162)">let</span><span style="font-variant-ligatures:no-common-ligatures;color:rgb(0,0,0)"> testURL = </span><span style="font-variant-ligatures:no-common-ligatures;color:rgb(79,129,135)">baseURL</span><span style="font-variant-ligatures:no-common-ligatures;color:rgb(0,0,0)">.</span><span style="font-variant-ligatures:no-common-ligatures">appendingPathComponent</span><span style="font-variant-ligatures:no-common-ligatures;color:rgb(0,0,0)">(</span><span style="font-variant-ligatures:no-common-ligatures;color:rgb(209,47,27)">"bar"</span><span style="font-variant-ligatures:no-common-ligatures;color:rgb(0,0,0)">)</span></p>
<p style="margin:0px;font-size:11px;line-height:normal;font-family:menlo;color:rgb(0,0,0);min-height:13px"><span style="font-variant-ligatures:no-common-ligatures"></span><br></p>
<p style="margin:0px;font-size:11px;line-height:normal;font-family:menlo;color:rgb(0,132,0)"><span style="font-variant-ligatures:no-common-ligatures;color:rgb(62,30,129)">print</span><span style="font-variant-ligatures:no-common-ligatures;color:rgb(0,0,0)">(</span><span style="font-variant-ligatures:no-common-ligatures;color:rgb(79,129,135)">url</span><span style="font-variant-ligatures:no-common-ligatures;color:rgb(0,0,0)"> </span><span style="font-variant-ligatures:no-common-ligatures;color:rgb(62,30,129)">==</span><span style="font-variant-ligatures:no-common-ligatures;color:rgb(0,0,0)"> </span><span style="font-variant-ligatures:no-common-ligatures;color:rgb(79,129,135)">newURL</span><span style="font-variant-ligatures:no-common-ligatures;color:rgb(0,0,0)">) </span><span style="font-variant-ligatures:no-common-ligatures">// prints false</span></p>
<p style="margin:0px;font-size:11px;line-height:normal;font-family:menlo;color:rgb(0,132,0)"><span style="font-variant-ligatures:no-common-ligatures;color:rgb(62,30,129)">print</span><span style="font-variant-ligatures:no-common-ligatures;color:rgb(0,0,0)">(</span><span style="font-variant-ligatures:no-common-ligatures;color:rgb(79,129,135)">url</span><span style="font-variant-ligatures:no-common-ligatures;color:rgb(0,0,0)">.</span><span style="font-variant-ligatures:no-common-ligatures;color:rgb(112,61,170)">path</span><span style="font-variant-ligatures:no-common-ligatures;color:rgb(0,0,0)"> </span><span style="font-variant-ligatures:no-common-ligatures;color:rgb(62,30,129)">==</span><span style="font-variant-ligatures:no-common-ligatures;color:rgb(0,0,0)"> </span><span style="font-variant-ligatures:no-common-ligatures;color:rgb(79,129,135)">newURL</span><span style="font-variant-ligatures:no-common-ligatures;color:rgb(0,0,0)">.</span><span style="font-variant-ligatures:no-common-ligatures;color:rgb(112,61,170)">path</span><span style="font-variant-ligatures:no-common-ligatures;color:rgb(0,0,0)">) </span><span style="font-variant-ligatures:no-common-ligatures">// prints true</span></p>
<p style="margin:0px;font-size:11px;line-height:normal;font-family:menlo;color:rgb(0,0,0);min-height:13px"><span style="font-variant-ligatures:no-common-ligatures"></span><br></p>
<p style="margin:0px;font-size:11px;line-height:normal;font-family:menlo;color:rgb(0,132,0)"><span style="font-variant-ligatures:no-common-ligatures;color:rgb(62,30,129)">print</span><span style="font-variant-ligatures:no-common-ligatures;color:rgb(0,0,0)">(</span><span style="font-variant-ligatures:no-common-ligatures;color:rgb(79,129,135)">url</span><span style="font-variant-ligatures:no-common-ligatures;color:rgb(0,0,0)"> </span><span style="font-variant-ligatures:no-common-ligatures;color:rgb(62,30,129)">==</span><span style="font-variant-ligatures:no-common-ligatures;color:rgb(0,0,0)"> </span><span style="font-variant-ligatures:no-common-ligatures;color:rgb(79,129,135)">testURL</span><span style="font-variant-ligatures:no-common-ligatures;color:rgb(0,0,0)">) </span><span style="font-variant-ligatures:no-common-ligatures">// prints true</span></p>
<p style="margin:0px;font-size:11px;line-height:normal;font-family:menlo;color:rgb(0,132,0)"><span style="font-variant-ligatures:no-common-ligatures;color:rgb(62,30,129)">print</span><span style="font-variant-ligatures:no-common-ligatures;color:rgb(0,0,0)">(</span><span style="font-variant-ligatures:no-common-ligatures;color:rgb(79,129,135)">url</span><span style="font-variant-ligatures:no-common-ligatures;color:rgb(0,0,0)">.</span><span style="font-variant-ligatures:no-common-ligatures;color:rgb(112,61,170)">path</span><span style="font-variant-ligatures:no-common-ligatures;color:rgb(0,0,0)"> </span><span style="font-variant-ligatures:no-common-ligatures;color:rgb(62,30,129)">==</span><span style="font-variant-ligatures:no-common-ligatures;color:rgb(0,0,0)"> </span><span style="font-variant-ligatures:no-common-ligatures;color:rgb(79,129,135)">testURL</span><span style="font-variant-ligatures:no-common-ligatures;color:rgb(0,0,0)">.</span><span style="font-variant-ligatures:no-common-ligatures;color:rgb(112,61,170)">path</span><span style="font-variant-ligatures:no-common-ligatures;color:rgb(0,0,0)">) </span><span style="font-variant-ligatures:no-common-ligatures">// prints true</span></p></div><div class="gmail_default" style="font-family:georgia,serif"><br></div><div class="gmail_default" style="font-family:georgia,serif">Zhaoxin</div><div class="gmail_default" style="font-family:georgia,serif"><br></div></div><div class="gmail_extra"><br><div class="gmail_quote">On Sat, Oct 15, 2016 at 11:19 AM, Jens Alfke <span dir="ltr"><<a href="mailto:jens@mooseyard.com" target="_blank">jens@mooseyard.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><span class=""><br>
> On Oct 14, 2016, at 5:16 PM, zh ao via swift-users <<a href="mailto:swift-users@swift.org">swift-users@swift.org</a>> wrote:<br>
><br>
> 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 URL equality?<br>
<br>
</span>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.<br>
<span class="HOEnZb"><font color="#888888"><br>
—Jens<br>
<br>
</font></span></blockquote></div><br></div>