开发者

Return object at Index number from Array

开发者 https://www.devze.com 2023-04-06 12:02 出处:网络
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开发

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

精彩评论

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