#import <Foundation/Foundation.h>
int main(void) {
NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
int i;
// NSArrayをループする
[[NSArray]] *array = [NSArray arrayWithObjects:@"aaa", @"bbb", @"ccc", @"ddd", nil];
for (i = 0; i < [array count]; i++) {
NSLog(@"index: %d, value: %@\n", i, [array objectAtIndex:i]);
}
// NSDictionaryをループする
NSDictionary *dict = [NSDictionary dictionaryWithObjectsAndKeys:
@"futaba", @"name", [NSNumber numberWithInt:4], @"age",
@"white", @"color", nil];
NSArray *keys = [dict allKeys];
for (i = 0; i < [keys count]; i++) {
NSLog(@"key: %@, value: %@\n", [keys objectAtIndex:i], [dict objectForKey:[keys objectAtIndex:i]]);
}
[pool drain];
return 0;
}
最終更新:2009年05月09日 17:36