开发者

how to get fixed number of strings from an NSmutable array in iphone?

i am getting 100 elements from xml and storing into an nsmutablearray.But every time i need to display only 10开发者_如何学JAVA elements how to get 10 out of 100?


NSArray *newArray = [oldArray subarrayWithRange:NSMakeRange(0, 9)];

This should do the trick for you. You can create the range based on your requirements.


Create a new array adding only those 10 objects you wish to use / display.


You can slice your array:

 -[NSArray subarrayWithRange:]

E.g.:

NSArray* subArray = [myArray subarrayWithRange:NSMakeRange(10, 20)];


while displaying put the condition like for(int i=0;i<10;i++)

and use this also

if(i>=10)
return;
0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜