有没有办法在进程之间共享核心数据存储? [英] Is there a way of sharing a Core Data store between processes?

查看:140
本文介绍了有没有办法在进程之间共享核心数据存储?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想要做什么?


  1. Core数据存储在磁盘上。


  2. 一个命令行过程,它写入与访问的数据存储相同的数据存储。 UI。


为什么?



所以命令行进程可以一直运行,但用户可以退出UI进程并忘记应用程序,直到他们需要查看捕获的数据。



我尝试了什么?



我已经阅读了在线程之间共享数据存储,并在此之前实现了一次,但我在文档或网络上找不到任何东西,指示如何在进程之间共享存储。



是否只需将两个进程都指向同一个数据存储文件?我已经尝试过这个简要。它似乎工作正常,但我担心我可能会遇到锁定等问题,当它真的处于压力下。



最后 / p>

我真的很感激有人给我指出与这个方向一致的方向。感谢。

解决方案

近两年来,我刚刚找到了一个更好的方法。



答案似乎在于Sync Services。我甚至没有意识到它存在!有一个很好的帖子关于这个:



http://www.timisted.net/blog/archive/core-data-and-sync-services/



我没有尝试过这个与我的应用程序,但它似乎是一个很好的方式在两个进程或应用程序之间共享核心数据存储。



如果我遇到任何性能问题,我会相应地更新这个答案,但这似乎是苹果推荐的做法。


What am I trying to do?

  1. A UI process that reads data from a Core Data store on disk. It wouldn't need to edit the data, just read and display the data.

  2. A command line process that writes to the same data store as accessed by the UI.

Why?

So that the command line process can be running all the time but the user can quit the UI process and forget about the app until they need to look at the data it's captured.

What would be the simplest and most reliable way of achieving this?

What Have I Tried?

I've read up on sharing a data store between threads and implemented this once before, but I can't find anything in the docs or on the web indicating how to share a store between processes.

Is it as simple as pointing both processes at the same data store file? I've experimented with this briefly. It appeared to work OK, but I'm worried I might run into problems with locking etc when it's really put under stress.

Finally

I'd really appreciate someone giving me pointers on what direction to go with this. Thanks.

解决方案

Nearly two years on, and I've just found a much better way of doing this.

The answer seems to lie with Sync Services. I didn't even realise it existed! There's an excellent post about this at:

http://www.timisted.net/blog/archive/core-data-and-sync-services/

I've not tried this with my app yet, but it seems like an excellent way of sharing a core data store between two processes or applications.

If I experience any performance issues, I'll update this answer accordingly, but this seems like the Apple recommended way of doing it.

这篇关于有没有办法在进程之间共享核心数据存储?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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