【发布时间】:2011-09-19 19:21:03
【问题描述】:
如何确定X在按Y排序的数组中的索引号?
我想说类似 "The 6th record out of 26" 其中 [array count] 是 26 而 'F' 是我要在包含字母的数组中查找的记录?
【问题讨论】:
标签: iphone arrays search nsarray
如何确定X在按Y排序的数组中的索引号?
我想说类似 "The 6th record out of 26" 其中 [array count] 是 26 而 'F' 是我要在包含字母的数组中查找的记录?
【问题讨论】:
标签: iphone arrays search nsarray
你可以使用:
[array indexOfObject:@"F"];
这将返回6
和:
[array objectAtIndex:6];
返回F
【讨论】:
在数组上使用indexOfObject(或类似的,根据你的需要和对象)消息之类的
查看 Apple 的 NSArray 类参考 here 并转到实例方法部分。
【讨论】: