views:

36

answers:

2

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  A: 

Use it in this way:

NSPredicate *predicate = [NSPredicate predicateWithFormat:@"FriendStatus == 1"];

NSMutableArray *filtered = [MessageArray filterUsingPredicate:predicate];

iPhoneDev
A: 

Read Predicates Programming Guide: http://developer.apple.com/mac/library/documentation/Cocoa/Conceptual/Predicates/Articles/pUsing.html

There are example using predicates with arrays.

jamapag