在保存核心数据之前销毁对象 [英] Destroying an object in Core Data before it's saved

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

问题描述

如果我像这样在Core Date(使用Magical Record)中创建一个新的Custom Object

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.

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

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