Reputation: 641
// Person.h
@interface Person : NSObject
@property (nonatomic, strong) NSString *firstName;
@property (nonatomic, strong) NSMutableArray *phoneNumbers;
@property (nonatomic, strong) UIImage *personImage;
@property (nonatomic, strong) NSNumber* recordID;
- (id)initWithPerson:(Person *)person;
@end
I am fetching the contact from the address book and adding it into custom class Person. Now for every contact in address book there might be multiple number so i have used NSMutableArray phoneNumbers , Now i need to search the contact and get the name of the Person .
I have Tried doing like this :
NSPredicate *predicate =
[NSPredicate predicateWithFormat:@"phoneNumbers like %@",contactNumber];
NSArray *filtered = [addressBookData filteredArrayUsingPredicate:predicate];
I am getting Nil in filtered array. Please suggest me how to solve this problem.
Upvotes: 1
Views: 778
Reputation: 119031
Instead of like
you should be using contains
to compare the contents of the array rather than the array itself.
Upvotes: 1