问题
I have a mutable array of custom objects. I want to filter that array by attribute of the object, for example myObject.attributeOne.
How can I create the NSPredicate to use with
[myArrayOfObjects filterUsingPredicate:<the_predicate>]
回答1:
Use it in this way:
NSPredicate *predicate = [NSPredicate predicateWithFormat:@"FriendStatus == 1"];
NSMutableArray *filtered = [MessageArray filteredArrayUsingPredicate:predicate];
来源:https://stackoverflow.com/questions/3386079/use-nspredicate-to-filter-by-object-attribute