NSManagedObjectContextObjectsDidChangeNotification不总是立即调用 [英] NSManagedObjectContextObjectsDidChangeNotification not always called instantly

查看:194
本文介绍了NSManagedObjectContextObjectsDidChangeNotification不总是立即调用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个Mac应用程序使用NSPersistentDocument。我想在对象被删除时收到通知,以使用Core Data保存此信息。所以我正在听NSManagedObjectContextObjectsDidChangeNotification。通常,当对象被删除时,它被立即调用,但有时它仅在持久文档被保存之后被调用,所有被删除的对象不被通知。因为我想让用户直接导出所有现有对象(而不是已删除的),我必须做什么才能立即通知保存删除信息,或者我必须以另一种方式使用它?

$ NSManagedObjectContextObjectsDidChangeNotification不再频繁或快速地在10.7上与10.6中发布的那样发布。

您可以通过调用 - [NSManagedObjectContext processPendingChanges] 来强制Core Data发出通知(假设有更改)。


I have an Mac Application using a NSPersistentDocument. I want to get notified when Objects are deleted to save this information using Core Data. So I'm listening for NSManagedObjectContextObjectsDidChangeNotification. Often it is called instantly when objects are deleted, but sometimes it is only called after the persistent document is saved with all deleted objects not being notified before. Because I want to let the user directly export all existing objects (and not the deleted anymore) what to I have to do to become notified instantly to save the delete information or do I have to use it in another way?

解决方案

NSManagedObjectContextObjectsDidChangeNotification is no longer issued as frequently or quickly on 10.7 as on 10.6. You can force Core Data to issue the notification (assuming there are changes) by calling -[NSManagedObjectContext processPendingChanges].

这篇关于NSManagedObjectContextObjectsDidChangeNotification不总是立即调用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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