I have an NSArray
which holds Foo
objects defined like so:
@interface Foo : NSObject <NSCopying> {
NSString *name;
}
@property (nonatomic, retain) NSString *name;
@end
and the query:
NSPredicate *filterPredicate = [NSPredicate predicateWithFormat:@"name BEGINSWITH[cd] %@", filterString];
//NSPredicate *filterPredicate = [NSPredicate predicateWithFormat:@"name CONTAINS[cd] %@", filterString];
filteredArray = [[originalArray filteredArrayUsingPredicate:filterPredicate] mutableCopy];
and this is not working. I always get 0 results.
So, my question is:
Should I always use NSPredicate
for searching only NSDictionary
objects with a certain key or can I use it for searching any object as long as there is a property/method that matches the query (in this case: name)?
Thanks in advance