NSPredicate check NSArray if object has one of several ID

Viewed 3764

Little diifficult to explain but I am trying to use NSPredicate for filtering an array with custom NSManagedObject by ids. I have a server that can send update, delete or add new objects, and I need to control if those objects from the JSON file already exist, if exist just update them or insert to core data if not.

I am using this predicate now :

   NSPredicate *predicate = [NSPredicate predicateWithFormat:@"storeId != %@", [jsonFile valueForKey:@"Id"];

Where jsonFile contains unparsed Store objects. But with this predicate, it will give me a huge array, since one id will be unlike some storeId, and next id will match.

Json file is some sort of this :

     "Stores":[{
          "id":1,
          "name":"Spar",
          "city":"London"
          }
          {
           "id":2,
           "name":"WalMart",
           "city":"Chicago"
       }];
2 Answers
Related