1
我有NSMutableArray
,数据如“John”,“Phillip”,“John”,“Andrea”。我也有一个字符串“约翰”。我需要在NSMutableArray
中找到该字符串,并定义哪个索引将显示其他数组中的其他数据。在我的情况下,指数是0和2在NSArray中查找一个字符串的所有索引
这个节目只有第一
NSInteger index = [array indexOfObject:String];
是的;好的解决方案 – trojanfoe
我应该如何在[data objectAtIndex:allPositions]中使用这个allPostions?我需要整数来显示数据。 – WildWorld
@WildWorld根据您的情况,您可以[使用块枚举您的索引集](http://stackoverflow.com/a/4209289/335858),或者使用'getIndexes将其转换为'NSInteger'数组:maxCount:inIndexRange:'方法。 – dasblinkenlight