Filtering NSMutableArray based on enum property
- by Marty
I've got an NSMutableArray filled with objects of type "GameObject". GameObject has a number of properties, one of which being "gameObjectType" . "gameObjectType" is of type GameObjectTypeEnum. I want to be able to filter this NSMutableArray so only GameObjects of a certain type are returned. I've got the following in place, but it's giving me a "BAD ACCESS" error:
NSPredicate *predicate = [NSPredicate predicateWithFormat:@"gameObjectType = %@", gameObjectType];
return [gameObjects filteredArrayUsingPredicate:predicate];
Is it possible to pass a "custom" type (ie, this enum I've defined) into the predicateWithFormat call?