ios - Core Data duplicate entries -
i'm importing data api that's giving me json data. each object gets added core data has attribute named "id". want able check if id in core data after initial import. have written code out far:
- (void)mergedata: (nsstring *)entitydescription { nspredicate *pred = [nspredicate predicatewithformat:@"id == %@", _bank.id]; // bank entity // id key 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]; (nsmanagedobject *object in items) { // loop on items , check see if ids match ids feed // if of them don't match, add new ids if (!match) { // add new object // i'm not sure how implement part } }
but know it's not complete , i'm not sure how implement rest of code part. appreciated.
Comments
Post a Comment