diff options
| author | Tolga Beser <mathman290@gmail.com> | 2015-10-15 14:09:36 -0700 | 
|---|---|---|
| committer | Tolga Beser <mathman290@gmail.com> | 2015-10-15 14:09:36 -0700 | 
| commit | b78a67c9fc29aac44848707f8119048286890a8d (patch) | |
| tree | 8e5e112a6e68199068a46b8c460f2b5f6d10f6c3 | |
| parent | 66bc42e31bf62a1592f9b763e12c0b963b3e7d3d (diff) | |
Mutable And Immutable Changing
Added how to switch objects between the two types with examples.
| -rw-r--r-- | objective-c.html.markdown | 8 | 
1 files changed, 7 insertions, 1 deletions
| diff --git a/objective-c.html.markdown b/objective-c.html.markdown index cf6bf780..30bb8843 100644 --- a/objective-c.html.markdown +++ b/objective-c.html.markdown @@ -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) | 
