I am trying to search on NSMutableArray
with two levels drill down with custom objects, I tried using SELF
and ANY
but no luck.
I have an NSMutableArray
say contentArray
Content Array
contentArray
{
OBJECTA,
OBJECTA
}
Which has custom objects (OBJECTA
), objectA
in turn has a custom object called Customer
OBJECTA:
@interface OBJECTA : NSObject
{
@property (strong,nonatomic) Customer * selectedCustomer;
}
@end
CUSTOMER:
@interface Customer : NSObject
@property(strong,nonatomic) NSString* Customer_Name;
@end
Now how I will be able to search contentArray
for Customer_Name
using NSPredicate
?
Try like this way if you want to match exact name
NSPredicate *predicate = [NSPredicate predicateWithFormat:@"selectedCustomer.Customer_Name LIKE '%@'", searchName];
If you want to check name contains than
NSPredicate *predicate = [NSPredicate predicateWithFormat:@"selectedCustomer.Customer_Name CONTAINS[cd] %@", searchName];