core data怎么删除修改数据
展开全部
NSFetchRequest *fetchRequest = [NSFetchRequest fetchRequestWithName:YOUR_ENTITY_NAME];
fetchRequest.predicate = [NSPresdicate predicateWithFormat:@\"fid == 3\"];
NSError *error;
NSArray *fetchResult = [YOUR_MANAGED_OBJECT_CONTEXT executeRequest:fetchRequest error:&error];
if(!error){
for(Entry*object in fetchResult) {
[YOUR_MANAGED_OBJECT_CONTEXT delete:object];
}
}
if([YOUR_MANAGED_OBJECT_CONTEXT hasChanges]) {
[YOUR_MANAGED_OBJECT_CONTEXT save:error];
}
fetchRequest.predicate = [NSPresdicate predicateWithFormat:@\"fid == 3\"];
NSError *error;
NSArray *fetchResult = [YOUR_MANAGED_OBJECT_CONTEXT executeRequest:fetchRequest error:&error];
if(!error){
for(Entry*object in fetchResult) {
[YOUR_MANAGED_OBJECT_CONTEXT delete:object];
}
}
if([YOUR_MANAGED_OBJECT_CONTEXT hasChanges]) {
[YOUR_MANAGED_OBJECT_CONTEXT save:error];
}
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询