Reputation: 2575
Is there any way to get the indices of the same string (that appears more than once) in a single array? I know I can find a specific string's location using:
[nameOfArray indexOfObject:@"apple"]
Of course, I could create a for loop essentially using the same code above and ignoring the previous "apples" found. I can't help to feel that there is a simpler (built-in) way to do this in objective-c. Am I right?
Thank you all in advance.
Upvotes: 0
Views: 76
Reputation: 1022
You could use indexesOfObjectsPassingTest
with the "test" block being a block that tests for equality.
Upvotes: 3