核心数据重复条目

我正在从提供JSON数据的API导入数据。 添加到核心数据中的每个对象都有一个名为“id”的属性。 我希望能够在初始导入后检查id是否已经在核心数据中。 到目前为止,我已经编写了这段代码:

- (void)mergeData: (NSString *)entityDescription { NSPredicate *pred = [NSPredicate predicateWithFormat:@"id == %@", _bank.id]; // Bank is the entity // id is the key from the raw JSON NSFetchRequest *fetch = [[NSFetchRequest alloc] init]; NSError *error = nil; [fetch setEntity:[NSEntityDescription entityForName:@"Banks" inManagedObjectContext:self.managedObjectContext]]; [fetch setPredicate:pred]; NSArray *items = [self.managedObjectContext executeFetchRequest:fetch error:&error]; for (NSManagedObject *object in items) { // Loop over all the items and check to see if the ids match with any ids from the feed // if any of them don't match, add the new ids if (!match) { // add new object // I'm not sure how to implement this part } } 

但我知道它不完整,我不知道如何实现这部分的其余代码。 任何帮助,将不胜感激。