• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Properly comparing file NSURLs for equality?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Properly comparing file NSURLs for equality?


  • Subject: Re: Properly comparing file NSURLs for equality?
  • From: Lee Ann Rucker <email@hidden>
  • Date: Fri, 27 May 2011 17:34:20 -0700

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 (email@hidden)

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:

This email sent to email@hidden

References: 
 >Properly comparing file NSURLs for equality? (From: Sean McBride <email@hidden>)
 >Re: Properly comparing file NSURLs for equality? (From: Mike Abdullah <email@hidden>)

  • Prev by Date: Re: Properly comparing file NSURLs for equality?
  • Next by Date: Re: Properly comparing file NSURLs for equality?
  • Previous by thread: Re: Properly comparing file NSURLs for equality?
  • Next by thread: iOS programming (who does what to whom?)
  • Index(es):
    • Date
    • Thread