引用来自NSManagedobjectContext文档的-undo方法:
Sends an undo message to the receiver’s undo manager,asking it to reverse the latest uncommitted changes applied to objects in the object graph.
要扭转最新的未提交更改,听起来很简单吧?
但是,实际情况并非如此!即使我使用托管对象上的更改保存上下文,以下-undo调用仍将成功撤消更改.这不是针对文档中陈述的内容吗?
也许我做错了什么?如果需要,我可以发布我的小测试代码.我真的很困惑.
解决方法
核心数据编程指南更详细:
Change and Undo Management
A context keeps strong references to managed objects that have pending
changes (insertions,deletions,or updates) until the context is sent
a save:,reset,rollback,or dealloc message,or the appropriate
number of undos to undo the change.The undo manager associated with a context keeps strong references to
any changed managed objects. By default,in OS X the context’s undo
manager keeps an unlimited undo/redo stack. To limit your
application’s memory footprint,you should make sure that you scrub
(usingremoveAllActions
) the context’s undo stack as and when
appropriate. Unless you keep a strong reference to a context’s undo
manager,it is deallocated with its context.
文档中的措辞/词汇不清晰或不一致.我相信,在适合您的应用程序时,您应该在上下文的undoManager属性上调用removeAllActions,以避免无限的内存增长.
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。