objective-ccore-data

Core data select objects from an array


I was wondering if I could select objects based on a predicate with an array... for example

Code:

[NSPredicate predicateWithFormat:@"id=%@", arrayOfID];

Will it work? If no, how can I do it?


Solution

  • The correct predicate would be

    [NSPredicate predicateWithFormat:@"id IN %@", arrayOfID];
    

    Assuming that arrayOfId contains objects of the same type as id (e.g. NSNumbers or NSStrings).