I have a category of NSMutableArray which has a deletion method:
@interface NSMutableArray(MyCategory)
- (void) deleteItemsMatchingCriteria: (SomeCriteria) theCriteria;
@end
How should this be implemented?
To iterate through arrays I usually use enumerateObjectsUsingBlock: but of course one cannot delete an item from the array while in the middle of the iteration.
Is there a canonical way of doing this for arrays in general, and does it differ if the method doing the deletion is a category of the array?
The simplest way to do it would be to use
indexesOfObjectsPassingTest:method: