On May 27, 2011, at 5:06 PM, Mike Abdullah wrote:

> It is a bit of a knotty problem. I've ended up with:
> 
> - (BOOL)ks_isEqualToURL:(NSURL *)otherURL;
> {
>    BOOL result = [self isEqual:otherURL];
> 
>   // For file: URLs the default check might have failed because they 
> reference the host differently. If so, fall back to checking paths
>    if (!result && [self isFileURL] && [otherURL isFileURL])
>    {
>        result = [[self path] isEqualToString:[otherURL path]];
>    }
> 
>    return result;
> }

That can fail in the circumstances from my code's comment:

   /*
    * [NSURL isEqualTo:] fails when a path has a trailing slash and
    * an otherwise matching one doesn't. Standardize the path first
    * and use localizedCompare in case the characters were composited 
differently.
    */
   if ([[[self path] stringByStandardizingPath]
         localizedCompare:[[inURL path] stringByStandardizingPath]] == 
NSOrderedSame) {
      return YES;
   }

_______________________________________________

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Reply via email to