Ios 从核心数据实体中删除依赖于两个属性的对象

Ios 从核心数据实体中删除依赖于两个属性的对象,ios,core-data,Ios,Core Data,在我的应用程序中,如果两个属性值等于一个字符串变量,我需要删除核心数据对象。这必须通过按钮操作来完成。如何确定要删除的对象 NSEntityDescription *entity=[NSEntityDescription entityForName:@"entityName" inManagedObjectContext:context]; NSFetchRequest *fetch=[[NSFetchRequest alloc] init]; [fetch setEntity:ent

在我的应用程序中,如果两个属性值等于一个字符串变量,我需要删除核心数据对象。这必须通过按钮操作来完成。如何确定要删除的对象

 NSEntityDescription *entity=[NSEntityDescription entityForName:@"entityName" inManagedObjectContext:context];
  NSFetchRequest *fetch=[[NSFetchRequest alloc] init];
  [fetch setEntity:entity];
NSPredicate *predicate = [NSPredicate predicateWithFormat:@"(value1 == %@) AND (value2 == %@)", data1, data2];
 [fetch setPredicate:predicate];
  //... add sorts if you want them
  NSError *fetchError;
  NSArray *fetchedData=[self.moc executeFetchRequest:fetch error:&fetchError];
 for (NSManagedObject *product in fetchedProducts) {
    [context deleteObject:product];
  }