Created
April 23, 2014 13:55
-
-
Save Ciechan/11216080 to your computer and use it in GitHub Desktop.
NSSet trivia
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
NSMutableString *s = [NSMutableString stringWithString:@"Hello"]; | |
NSSet *set = [NSSet setWithObjects:s, nil]; | |
NSLog(@"%d", [set containsObject:s]); | |
[s appendString:@"BLA"]; | |
NSLog(@"%d", [set containsObject:s]); | |
NSLog(@"%d", [set.allObjects containsObject:s]); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Just for reference: the docs clearly state that you must not modify objects in such a way that their hash changes while they are in certain collections. ;)
So don’t do it people!
https://developer.apple.com/library/mac/documentation/cocoa/reference/foundation/Protocols/NSObject_Protocol/Reference/NSObject.html