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