Core Data NSFetchRequest with predicate

53 views
Skip to first unread message

M. S. Hrishikesh

unread,
Mar 1, 2012, 11:40:38 AM3/1/12
to cocoa-...@googlegroups.com
Hi 

I have populated my test core data with 10 entries. When I setup a fetch request with a predicate this way:

---
NSString *key = @"tag";

NSPredicate *pred = [NSPredicate predicateWithFormat:@"%K like %@",key,@"personality"];

 

[req setPredicate:pred];


NSArray *results = [self.managedObjectContext executeFetchRequest:req error:&error];
---

The array results has only 1 element. But all of my records have tag set to "personality" (without the quotes). In fact when I set the predicate to nil, fetch all records and print the tag I can see that all the tags are set to "personality".

Am I doing something wrong? How do I get all records with tag set to "personality"

Thanks
Hrishi


Reply all
Reply to author
Forward
0 new messages