summaryrefslogtreecommitdiffhomepage
path: root/objective-c.html.markdown
diff options
context:
space:
mode:
authorLevi Bostian <levi.bostian@gmail.com>2015-10-18 12:00:55 -0500
committerLevi Bostian <levi.bostian@gmail.com>2015-10-18 12:00:55 -0500
commit3022f639a976f8d6e4adfe523d4fcb3408855038 (patch)
tree5cc59187aff1c379b0f982e6d854d5e50bbc9a52 /objective-c.html.markdown
parent5e05ac6b045d7726200fa8835f88ca6dc8cbc417 (diff)
parentb78a67c9fc29aac44848707f8119048286890a8d (diff)
Merge pull request #1539 from TolgaB/patch-1
Mutable And Immutable Changing
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)