As mentioned in jtbandes, you can write a method NSArrayas a category if you are going to do this a lot. Something like that:
@interface NSArray (FindClass)
- (NSMutableArray *) findObjectsOfClass:(Class)theClass
@end
then
@implementation NSArray (FindClass)
- (NSMutableArray *) findObjectsOfClass:(Class)theClass {
NSMutableArray *results = [[NSMutableArray alloc] init];
for (id obj in self) {
if ([obj isKindOfClass:theClass])
[results addObject:obj];
}
return [results autorelease];
}
@end
then when you want to use it just do:
NSMutableArray *objects = [myArray findObjectsOfClass:[FooType class]];
which should contain all the objects of the specified class.
: , , - :/