Using -isEqual: is a great way to detect if two NSURLs are equal. But this approach won’t work if you need to know if the two URLs point to the same file, like in this case:
/var/some/path
/private/var/some/path
In OS X 10.7 and iOS 5 Apple added a new key (NSURLFileResourceIdentifierKey) to NSURL that makes implementing this check pretty straightforward:
- (BOOL)mn_identicalFileAtURL:(NSURL *)aURL
{
id fileURLID1;
[self getResourceValue:&fileURLID1 forKey:NSURLFileResourceIdentifierKey error:NULL];
id fileURLID2;
[aURL getResourceValue:&fileURLID2 forKey:NSURLFileResourceIdentifierKey error:NULL];
if (!fileURLID1 || !fileURLID2) return NO; // no file URLs?
return ([fileURLID1 isEqual:fileURLID2]);
}
