Yeah, NSIndexSet is one of the duller knives in the Foundation drawer. Who spec'd _that_ gomer? Obviously someone who forgot the dictum about keeping simple things... simple.
I like your solution, although I would like to see an actual IndexEnumerator class.
I do suggest that if your method declares an NSArray as its return value, that you ought to actually return one. Apple's advice on return types is that you should assume that they are correct, even though they might not be. (?!?)
I feel that it is worth the miniscule cost to rigorously honor the declaration -- it minimizes the odds of a subtle bug down the road.
So,my only adjustment will be to change the return to:
by kk — Mar 23
I like your solution, although I would like to see an actual IndexEnumerator class.
I do suggest that if your method declares an NSArray as its return value, that you ought to actually return one. Apple's advice on return types is that you should assume that they are correct, even though they might not be. (?!?)
I feel that it is worth the miniscule cost to rigorously honor the declaration -- it minimizes the odds of a subtle bug down the road.
So,my only adjustment will be to change the return to:
return [[targetArray copy] autorelease];