summaryrefslogtreecommitdiffhomepage
path: root/objective-c.html.markdown
diff options
context:
space:
mode:
Diffstat (limited to 'objective-c.html.markdown')
-rw-r--r--objective-c.html.markdown10
1 files changed, 8 insertions, 2 deletions
diff --git a/objective-c.html.markdown b/objective-c.html.markdown
index cf6bf780..f130ea0c 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)
@@ -682,7 +688,7 @@ addUp = ^(int n) { // Remove (int n) to have a block that doesn't take in any pa
mutableVar = 32; // Assigning new value to __block variable.
return n + outsideVar; // Return statements are optional.
}
-int addUp = add(10 + 16); // Calls block code with arguments.
+int addUp = addUp(10 + 16); // Calls block code with arguments.
// Blocks are often used as arguments to functions to be called later, or for callbacks.
@implementation BlockExample : NSObject