Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/objective-c/25.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/google-maps/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Objective c 如何输出这个字符串数组?_Objective C_Arrays_String - Fatal编程技术网

Objective c 如何输出这个字符串数组?

Objective c 如何输出这个字符串数组?,objective-c,arrays,string,Objective C,Arrays,String,假设我有一个字符串数组 [NSArray arrayWithObjects: @"red", @"blue", @"green", @"yellow", nil] 我如何实现这样的输出 红色是一种颜色 蓝色是一种颜色 绿色是一种颜色 黄色是一种颜色 谢谢 NSArray*初始化NSArray=[NSArray arrayWithObjects:@“红色”, NSArray *initializedNSArray = [NSArray arrayWithObjects: @"red",

假设我有一个字符串数组

[NSArray arrayWithObjects: @"red", @"blue", @"green", @"yellow", nil]
我如何实现这样的输出

红色是一种颜色
蓝色是一种颜色
绿色是一种颜色
黄色是一种颜色

谢谢

NSArray*初始化NSArray=[NSArray arrayWithObjects:@“红色”,
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
@“蓝色”, @“绿色”, @“黄色”, 无]
对于(int i=0;i您希望它使用哪种语言?您希望此输出到哪里?到文件、到stdout、到stderr?不要使用NSLog()对于普通的字符串输出。它预先提供了很多问题不需要的信息。我在xcode中使用Obj c,我需要输出为NSString格式,以便在textView中显示结果列表
NSArray *colors = ...;
for (NSString *color in colors) {
  NSLog(@"%@ is a color", color);
}