1

Possible Duplicate:
Enumerate NSArray using blocks to find and store all indexe's of all NSStrings in array

I am trying to get a NSIndexSet from an Array of objects. My question is related to getting the indexSet.

Can I get an indexSet by searching for a class using introspection? i.e. I have an array of numbers and strings. I want an index set of all the strings in the array.

Community
  • 1
  • 1
Bren
  • 13
  • 3

1 Answers1

4
NSIndexSet *indexSet = [myArray indexesOfObjectsPassingTest:^(id obj, NSUInteger idx, BOOL *stop){
    return [obj isKindOfClass:[NSString class]];
}];
rob mayoff
  • 375,296
  • 67
  • 796
  • 848