开发者

Return object at Index number from Array

How do I determine the index number of X in an array sorted by Y?

I want to say something like "The 6th record out of 26" where [array count] is 26 and 'F' is the record I'm looking for in an开发者_StackOverflow中文版 array containing the alphabet?


You can use:

[array indexOfObject:@"F"];

This would return 6

and:

[array objectAtIndex:6];

Which would return F


Use the indexOfObject (or the like, according to your needs and object) message or the like on the array

Look at Apple's NSArray Class reference here and go the Instance methods section.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜