Mutable And Immutable Changing

Added how to switch objects between the two types with examples.
This commit is contained in:
Tolga Beser 2015-10-15 14:09:36 -07:00
parent 66bc42e31b
commit b78a67c9fc

View File

@ -149,6 +149,12 @@ int main (int argc, const char * argv[])
[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)