summaryrefslogtreecommitdiffhomepage
path: root/objective-c.html.markdown
diff options
context:
space:
mode:
authorTolga Beser <mathman290@gmail.com>2015-10-15 14:09:36 -0700
committerTolga Beser <mathman290@gmail.com>2015-10-15 14:09:36 -0700
commitb78a67c9fc29aac44848707f8119048286890a8d (patch)
tree8e5e112a6e68199068a46b8c460f2b5f6d10f6c3 /objective-c.html.markdown
parent66bc42e31bf62a1592f9b763e12c0b963b3e7d3d (diff)
Mutable And Immutable Changing
Added how to switch objects between the two types with examples.
Diffstat (limited to 'objective-c.html.markdown')
-rw-r--r--objective-c.html.markdown8
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)