RosettaCodeData/Task/Associative-array-Iteration/Objective-C/associative-array-iteration-2.m
Ingy döt Net d066446780 langs a-z
2013-04-10 22:43:41 -07:00

18 lines
543 B
Objective-C

NSDictionary *myDict = [NSDictionary dictionaryWithObjectsAndKeys:
[NSNumber numberWithInt:13], @"hello",
[NSNumber numberWithInt:31], @"world",
[NSNumber numberWithInt:71], @"!", nil];
// iterating over keys:
NSEnumerator *enm = [myDict keyEnumerator];
id key;
while ((key = [enm nextObject])) {
NSLog(@"key = %@", key);
}
// iterating over values:
enm = [myDict objectEnumerator];
id value;
while ((value = [enm nextObject])) {
NSLog(@"value = %@", value);
}