Reputation: 145
I have NSMutableArray full of objects of two different types. I need to find out number of objects of certain type. Does exist some function like count to count objects of specific type, or I have to iterate through array and count them manually?
Thank you.
Upvotes: 0
Views: 47
Reputation: 500
Try this
NSInteger *countTypeA;
NSInteger *countTypeB;
for (id object in array) {
if ([object isKindOfClass:[firstType class]]) {
countTypeA++;
} else if ([object isKindOfClass:[secondType class]]){
countTypeB++;
}
}
Upvotes: 1