如何在Objective-C中将值附加到数组 [英] How to append values to an array in Objective-C
本文介绍了如何在Objective-C中将值附加到数组的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在这样做:
for(int i=0;i>count;i++)
{
NSArray *temp=[[NSArray alloc]initWIthObjects]i,nil];
NSLog(@"%i",temp);
}
它返回给我 0,1,2,3.... 一一计数,但我想要一个附加这些值 {0,1,2,3,4,5...} 的数组.这没什么大不了的,但我找不到它.我是 iPhone 新手.
It returns to me 0,1,2,3....counting one by one, but I want an array with appending these values {0,1,2,3,4,5...}. This is not a big deal, but I'm unable to find it. I am new to iPhone.
推荐答案
NSMutableArray *myArray = [NSMutableArray array];
for(int i = 0; i < 10; i++) {
[myArray addObject:@(i)];
}
NSLog(@"myArray:\n%@", myArray);
这篇关于如何在Objective-C中将值附加到数组的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文