Last active
August 29, 2015 14:00
-
-
Save jdriscoll/11097729 to your computer and use it in GitHub Desktop.
Mutable objects in set
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
#import <Foundation/Foundation.h> | |
void logIt(NSSet *set) { | |
NSLog(@"set: %@", set); | |
for (id object in set) { | |
NSLog(@"element with hash: %lu", (unsigned long)[object hash]); | |
} | |
} | |
int main(int argc, char *argv[]) { | |
NSMutableString *a = [@"a" mutableCopy]; | |
NSMutableString *b = [@"b" mutableCopy]; | |
NSSet *set = [NSSet setWithObjects:a, b, nil]; | |
logIt(set); | |
[b setString:@"a"]; | |
logIt(set); | |
} |
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
2014-04-19 17:14:15.877 Untitled 2[98114:507] set: {( | |
a, | |
b | |
)} | |
2014-04-19 17:14:15.879 Untitled 2[98114:507] element with hash: 1062 | |
2014-04-19 17:14:15.879 Untitled 2[98114:507] element with hash: 1065 | |
2014-04-19 17:14:15.880 Untitled 2[98114:507] set: {( | |
a, | |
a | |
)} | |
2014-04-19 17:14:15.880 Untitled 2[98114:507] element with hash: 1062 | |
2014-04-19 17:14:15.880 Untitled 2[98114:507] element with hash: 1062 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment