summaryrefslogtreecommitdiffhomepage
path: root/objective-c.html.markdown
diff options
context:
space:
mode:
authorJacob Ward <jacobward1898@gmail.com>2015-10-26 23:03:37 -0600
committerJacob Ward <jacobward1898@gmail.com>2015-10-26 23:03:37 -0600
commita0eb996415cc86cb72c44e793ebfacc3ec2d7b17 (patch)
tree516c83684b752f374758b9abd3b89be723478fd3 /objective-c.html.markdown
parent66bc42e31bf62a1592f9b763e12c0b963b3e7d3d (diff)
parent44ca091c73afe13ec8760021cfed1d77afc5e4a5 (diff)
Merge remote-tracking branch 'adambard/master'
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