Skip to content

Instantly share code, notes, and snippets.

@dnpp73
Created June 16, 2013 18:42
Show Gist options
  • Save dnpp73/5792971 to your computer and use it in GitHub Desktop.
Save dnpp73/5792971 to your computer and use it in GitHub Desktop.
- (void)viewDidLoad
{
[super viewDidLoad];
NSArray* baseArray = @[
[[NSObject alloc] init],
[[NSObject alloc] init],
[[NSObject alloc] init],
[[NSObject alloc] init]
];
NSMutableArray* (^arrayMaker)(NSArray*) = ^(NSArray* baseArray){
NSMutableArray* array = [NSMutableArray arrayWithCapacity:baseArray.count];
for (id obj in baseArray) {
[array addObject:obj];
}
return array.copy;
};
NSArray* arr1 = arrayMaker(baseArray);
NSArray* arr2 = arrayMaker(baseArray);
NSLog(@"arr1 -> %p", arr1);
NSLog(@"arr2 -> %p", arr2);
NSLog(@"== -> %d", (arr1 == arr2));
NSLog(@"isEqual -> %d", [arr1 isEqual:arr2]);
NSLog(@"isEqualToArray -> %d", [arr1 isEqualToArray:arr2]);
}
2013-06-17 03:39:58.199 isEqualTest[42330:c07] arr1 -> 0x75899c0
2013-06-17 03:39:58.200 isEqualTest[42330:c07] arr2 -> 0x7589a40
2013-06-17 03:39:58.200 isEqualTest[42330:c07] == -> 0
2013-06-17 03:39:58.201 isEqualTest[42330:c07] isEqual -> 1
2013-06-17 03:39:58.201 isEqualTest[42330:c07] isEqualToArray -> 1
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment