From f15a2b5f782b0f5fb2de6359353f948218860484 Mon Sep 17 00:00:00 2001 From: Levi Bostian Date: Thu, 26 Dec 2013 12:20:16 -0600 Subject: Add more data type examples. Add NSMutableSet examples. --- objective-c.html.markdown | 11 +++++++++-- 1 file 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 -- cgit v1.2.3