Skip to content

Instantly share code, notes, and snippets.

@odrobnik
Created November 12, 2012 17:09
Show Gist options
  • Save odrobnik/4060573 to your computer and use it in GitHub Desktop.
Save odrobnik/4060573 to your computer and use it in GitHub Desktop.
Comparing URLs
NSURL *a = [NSURL URLWithString:@"http://google.com/oliver.html"];
NSURL *b = [NSURL URLWithString:@"oliver.html" relativeToURL:[NSURL URLWithString:@"http://google.com"]];
if([a isEqual:b]) {
NSLog(@"Same"); // Not run
}
if([[a absoluteURL] isEqual:[b absoluteURL]]) {
NSLog(@"Same"); // Still not run
}
if([[a URLByStandardizingPath] isEqual:[b URLByStandardizingPath]]) {
NSLog(@"Same"); // Still not run
}
if([[a absoluteString] isEqualToString:[b absoluteString]]) {
NSLog(@"Same"); // Still not run
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment