在保存Core Data之前,销毁它 [英] Destroying an object in Core Data before it's saved

查看:161
本文介绍了在保存Core Data之前,销毁它的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如果我在Core Date(使用Magical Record)中创建一个新的自定义对象,如

If I create a new Custom Object in Core Date (using Magical Record) like so

List *list = [List MR_createInContext:_managedObjectContext];

然后我对它执行各种操作,例如设置其名称

And then I perform various actions on it, such as setting its name

list.name = @"Foobar List";

但是用户决定取消创建此列表,我需要删除吗?就像在里面,这个列表已经在内存中,即使我没有保存本地上下文与 [localContext MR_save];

But then the user decides to cancel the creation of this list, do I need to delete? As in, is this list already in memory even though I haven't saved the local context with [localContext MR_save];

推荐答案

如果在受管对象上下文中创建对象,它将在下次保存更改时保存。如果您不想保存,您必须将其删除。

If you create the object in the managed object context, it will get saved the next time you save changes. If you don't want to save it, you'll have to delete it.

这篇关于在保存Core Data之前,销毁它的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆