This question will sound like a newbie but i have gone through all threads for my solution which is still an issue for me. So i have an entity “LookUp” which has an attribute ‘descrip’.
Now my question is i want to fetch all values of attribute ‘descrip’.
Till now i have used all this queries:
[NSPredicate predicateWithFormat:@"descrip == %@",[NSNumber numberWithInt:1]];
[NSPredicate predicateWithFormat:@"descrip == %@",@"descrip"];
[NSPredicate predicateWithFormat:@"descrip == %@",[NSNumber numberWithBool:YES]];
if i fire a query
[NSPredicate predicateWithFormat:@"descrip == %@",@"Art Gallery"];
it returns me an array with the values associated with “Art Gallery”. The ‘descrip’ attribute contains 250 values like “Art Gallery”.
Please help it out. Thanks in advance.
NSPredicate is used to limit your results to entities that adhere to a certain restriction – like you said, descrip == @”Art Gallery” will return all entities that have a decrip attribute set to Art Gallery.
In your case, you do not want to restrict the entities in your query. Just perform your query without any predicate, and all entities will be returned. Now just loop over the entities, and get all values of descrip into a NSMutableSet or NSMutableDictionary, and you have your list of descrip values.