How do I share a Core Data store between processes using NSDistributedNotifications?

前端 未结 6 2041
星月不相逢
星月不相逢 2020-12-29 15:24

Background

I\'ve already posted a question about the basics of sharing a Core Data store between processes.

I\'m trying to implement the rec

6条回答
  •  死守一世寂寞
    2020-12-29 16:17

    I'd go with Mike's suggestion and just watch the store file for changes.

    Though it may not be the most efficient, I've had success using - [NSManagedObjectContext reset] from a second process when there's a change to a store. In my case case, the code is fairly linear — all I do is run a fetch request for some data after resetting. I don't know how this will work with bindings and a complicated UI, but you may be able to post a notification to manually update things if it's not handled automatically.

提交回复
热议问题