mirror of
https://github.com/adambard/learnxinyminutes-docs.git
synced 2024-12-23 09:41:36 +00:00
Add more data type examples.
Add NSMutableSet examples.
This commit is contained in:
parent
18f669089e
commit
f15a2b5f78
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user