user3762713
user3762713

Reputation: 101

How to set NSpredicate with AND condition to fetch Data

I am developing one iPad application using storyboard and core data .For my application need to fetch the data based on two condition. langCode = 'ESP' and code = 'P0001'. I set the NSPredicate in the following format

 NSString *language= @"ESP";
 NSString *itemCode = @"P0001";
 NSPredicate *predicateCardText = [NSPredicate predicateWithFormat:@"(langCode == %@)AND (code == %@)", language,itemCode]; 

But the fetch request returns empty array.I checked the database the object with langCode =ESP and code =P0001 is available in the database.But if I set AND condition in my NSPredicate, it returns empty array.

Upvotes: 0

Views: 259

Answers (1)

CW0007007
CW0007007

Reputation: 5681

Same as you would in Code:

     NSString *language= @"ESP";
     NSString *itemCode = @"P0001";
     NSPredicate *predic ateCardText = [NSPredicate predicateWithFormat:@"langCode == %@ && code == %@", language,itemCode];

Upvotes: 1

Related Questions