Created
June 16, 2013 18:42
-
-
Save dnpp73/5792971 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
- (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]); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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