mirror of
https://github.com/adambard/learnxinyminutes-docs.git
synced 2025-01-17 21:49:22 +01:00
Merge pull request #1539 from TolgaB/patch-1
Mutable And Immutable Changing
This commit is contained in:
commit
3022f639a9
@ -148,7 +148,13 @@ int main (int argc, const char * argv[])
|
||||
[mutableDictionary setObject:@"value1" forKey:@"key1"];
|
||||
[mutableDictionary setObject:@"value2" forKey:@"key2"];
|
||||
[mutableDictionary removeObjectForKey:@"key1"];
|
||||
|
||||
|
||||
// Change types from Mutable To Immutable
|
||||
//In general [object mutableCopy] will make the object mutable whereas [object copy] will make the object immutable
|
||||
NSMutableDictionary *aMutableDictionary = [aDictionary mutableCopy];
|
||||
NSDictionary *mutableDictionaryChanged = [mutableDictionary copy];
|
||||
|
||||
|
||||
// Set object
|
||||
NSSet *set = [NSSet setWithObjects:@"Hello", @"Hello", @"World", nil];
|
||||
NSLog(@"%@", set); // prints => {(Hello, World)} (may be in different order)
|
||||
|
Loading…
x
Reference in New Issue
Block a user