[英]Core data delete objects
我在应用程序中使用核心数据。 当我使用[context deleteObject:obj]
删除对象时,对象不会仅使用空字段删除。 如何永久删除对象? 提前致谢。 我使用表视图,当该视图中填充了核心数据中的数据时,有空行被删除了。 这是代码:
LNAppDelegate *appDelegate = [[UIApplication sharedApplication] delegate];
self.context = [appDelegate managedObjectContext];
self.accounts = [[NSArray alloc] init];
NSFetchRequest *fetchRequest = [[NSFetchRequest alloc] init];
NSEntityDescription *entity = [NSEntityDescription
entityForName:@"Accounts" inManagedObjectContext:self.context];
[fetchRequest setEntity:entity];
NSError *error;
self.accounts = [self.context executeFetchRequest:fetchRequest error:&error];
更改后确定要保存上下文吗?
NSError *error = nil;
if(![self.managedObjectContext save:&error])
{
/*
//Handle error
*/
NSLog(@"Unresolved error %@, %@", error, [error userInfo]);
}
另外,请确保您引用的是正确的上下文,因为可以有多个上下文。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.