disableUndoRegistration 仍然允许撤消操作
我想禁用 NSManagedObject 上的操作的撤消注册,但即使我显式调用disableUndoRegistration,它仍然会记录该操作。
我是否缺少一些明显的东西?
我还尝试分别在 viewWillAppear 和 viewWillDisappear 方法中启用/禁用。
这是一些示例代码...
#pragma mark -
#pragma mark NotesViewControllerDelegate methods
- (void)notesViewController:(NotesViewController *)controller didFinishWithSave:(BOOL)save
{
if (save)
{
[undoManager disableUndoRegistration];
[book setNotes:[controller getDataFromText]];
[undoManager enableUndoRegistration];
}
}
I want to disable undo registration for an operation on an NSManagedObject but it still records the operation even though I explicitly call disableUndoRegistration.
Is there something obvious I am missing?
I also tried to enable/disable in the viewWillAppear and viewWillDisappear methods, respectively.
Here is some example code...
#pragma mark -
#pragma mark NotesViewControllerDelegate methods
- (void)notesViewController:(NotesViewController *)controller didFinishWithSave:(BOOL)save
{
if (save)
{
[undoManager disableUndoRegistration];
[book setNotes:[controller getDataFromText]];
[undoManager enableUndoRegistration];
}
}
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您必须调用 [managementObjectContext processPendingChanges];在每个禁用和启用撤消注册的调用之前,因为核心数据队列更改为能够进行优化。
看
http://developer.apple.com/库/mac/#documentation/Cocoa/Conceptual/CoreData/Articles/cdUsingMOs.html
You have to call [managedObjectContext processPendingChanges]; before each of the calls that disable and enable the undo registration because Core Data queues changes to be able to do optimizations.
see
http://developer.apple.com/library/mac/#documentation/Cocoa/Conceptual/CoreData/Articles/cdUsingMOs.html