在使用核心数据删除 DetailView 控制器中的带有删除按钮的项目后,我需要使用 UITableView 更新 MainView 控制器中的表视图。
核心数据结构:http: //i.stack.imgur.com/GZ0k8.png
在 MainView 控制器中,我有一个带有订单的表格,按下订单将打开一个带有食物和订单的 detailview 控制器,我可以在其中删除订单。之后我需要[self popViewControllerAnimated:YES]
;
删除对象的代码,其中 self.orderItem - 订单传递给 DetailView 控制器:
[self.managedObjectContext deleteObject:self.orderItem];
NSError *error = nil;
if (![self.managedObjectContext save:&error]) {
// Replace this implementation with code to handle the error appropriately.
// abort() causes the application to generate a crash log and terminate. You should not use this function in a shipping application, although it may be useful during development.
NSLog(@"Unresolved error %@, %@", error, [error userInfo]);
abort();
}