Filtering NSMutableArray based on enum property

Posted by Marty on Stack Overflow See other posts from Stack Overflow or by Marty
Published on 2010-06-13T19:10:32Z Indexed on 2010/06/13 19:22 UTC
Read the original article Hit count: 163

Filed under:

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?

© Stack Overflow or respective owner

Related posts about objective-c