diff options
-rw-r--r-- | objective-c.html.markdown | 11 |
1 files changed, 9 insertions, 2 deletions
diff --git a/objective-c.html.markdown b/objective-c.html.markdown index 95012152..bbdbac4c 100644 --- a/objective-c.html.markdown +++ b/objective-c.html.markdown @@ -131,12 +131,19 @@ int main (int argc, const char * argv[]) NSDictionary *aDictionary = @{ @"key1" : @"value1", @"key2" : @"value2" }; NSObject *valueObject = aDictionary[@"A Key"]; NSLog(@"Object = %@", valueObject); // Print "Object = (null)" - // NSMutableDictionary also available as mutable dictionary object. + // NSMutableDictionary also available as a mutable dictionary object. + NSMutableDictionary *mutableDictionary = [NSMutableDictionary dictionaryWithCapacity:2]; + [mutableDictionary setObject:@"value1" forKey:@"key1"]; + [mutableDictionary setObject:@"value2" forKey:@"key2"]; + [mutableDictionary removeObjectForKey:@"key1"]; // Set object NSSet *set = [NSSet setWithObjects:@"Hello", @"Hello", @"World", nil]; NSLog(@"%@", set); // prints => {(Hello, World)} (may be in different order) - // NSMutableSet also available as mutable set object. + // NSMutableSet also available as a mutable set object. + NSMutableSet *mutableSet = [NSMutableSet setWithCapacity:2]; + [mutableSet addObject:@"Hello"]; + [mutableSet addObject:@"Hello"]; /////////////////////////////////////// // Operators |