开发者

How to Put an integer value into an array?

Supp开发者_JS百科ose I have to store indexpath.row values(i.e indexes) of table cells into an array. How can i achive that?

Please explain with a code snippet


NSArray (and other objective-c containers) stores objects, so you'll need to create NSNumber object to store it in array:

NSNumber *num  = [NSNumber numberWithInt:index];
[yourMutableArray addObject:num];

Also have a look at NSIndexSet(NSMutableIndexSet) classes - may be they will serve your purpose better


You could just store the NSIndexPath in the array.


what array you mean? you can create in your h. : NSInteger arr[10]; // make an array size 10

and then fill it with your values: for (int i = 0 ; i< 10 ; i++) {arr[i] = 1} for example..

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜