说我有一个字符串数组......
[NSArray arrayWithObjects: @"red", @"blue", @"green", @"yellow", nil]
我如何实现这样的输出......?
红色是一种颜色 蓝色是一种颜色 绿色是一种颜色 黄色是一种颜色
谢谢!
答案 0 :(得分:7)
NSArray *colors = ...;
for (NSString *color in colors) {
NSLog(@"%@ is a color", color);
}
答案 1 :(得分:0)
NSArray *initializedNSArray = [NSArray arrayWithObjects: @"red",
@"blue",
@"green",
@"yellow",
nil]
for( int i=0; i<4; ++i )
NSLog(@"%@ is a color \n", [initializedNSArray objectAtIndex: i];
// ^^^^^^^^^^^^^^^^^ to array it is earlier initialized to