iPhone &核心数据 - 删除 NSManagedObject?
我试图删除托管对象上下文,但不是删除对象本身,而是将所有即时变量设置为 null。 我在删除 NSManagedObjectContext 的瞬间时做错了什么吗?
@implementation MyManagedObject
- (BOOL)submitToServer
{
if (/*submitted successfully*/)
{
return YES;
}
else
{
[self.managedObjectContext deleteObject:self];
return NO;
}
}
@end
I'm trying to remove a managed object context, but instead of removing the object itself it sets all instant variables to null.
Am I doing anything wrong while deleting an instant of NSManagedObjectContext?
@implementation MyManagedObject
- (BOOL)submitToServer
{
if (/*submitted successfully*/)
{
return YES;
}
else
{
[self.managedObjectContext deleteObject:self];
return NO;
}
}
@end
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您必须在
deleteObject
之后调用[self.managementObjectContext save:nil]
才能将删除提交到持久存储。阅读有关 删除托管对象。You must call
[self.managedObjectContext save:nil]
afterdeleteObject
for the delete to be committed to the persistent store. Read more about deleting a managed object.