我一直试图找出这个问题2天了.我试图保存时不断收到错误.
//self.data is NSManagedObject. kAppDelegate.moc is the managed object context.
self.data = [NSEntityDescription insertNewObjectForEntityForName:@"Data"
inManagedObjectContext:kAppDelegate.moc];
[self.data setValue:[NSNumber numberWithBool:NO] forKey:@"isit"];
[self.data setValue:@"" forKey:@"name"];
NSError *error;
if(![self.data.managedObjectContext save:&error])
{
NSLog(@"Save did not complete successfully. Error: %@",
[error localizedDescription]);
}
Run Code Online (Sandbox Code Playgroud)
当我运行它时,它出现在控制台中:
"CoreData:错误:将托管对象0x10935d4c0(0x10935d420)从其上下文中删除后进行变更."
还有这个:
保存未成功完成.错误:(null)
我无法弄清楚为什么会发生这种情况,或者为什么错误是"空".