如何通过for语句或枚举打印NSArray对象?
可能的重复:
如何迭代 NSArray?
这是我的代码(用于示例):
NSArray *myArray = [NSArray arrayWithObjects:@"Red", @"Blue", @"Green", nil];
我想循环遍历数组,将每个字符串打印到控制台。
谢谢。
Possible Duplicate:
How do I iterate over an NSArray?
Here is my code (for example):
NSArray *myArray = [NSArray arrayWithObjects:@"Red", @"Blue", @"Green", nil];
I want loop through the array printing each string to the console.
Thanks.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
最简单的方法就是:
或者,如果您想使用快速枚举以您自己的方式打印每个对象:
The easiest way is just:
Or, if you want to use fast enumeration to print each object in your own way:
让我们找到最复杂的方法,好吗?
当然,你总是可以这样做:
Let's find the most complex way, shall we?
Of course, you can always just do it like this: