开发者

Can't merge data error with coredata

开发者 https://www.devze.com 2023-02-17 01:43 出处:网络
I have an app that uses coredata, but when I accidentally open the app 2 times from different locations I get his error message \"can\'t merge data\" when trying to close the app.

I have an app that uses coredata, but when I accidentally open the app 2 times from different locations I get his error message "can't merge data" when trying to close the app.

How can I prevent the other app from openi开发者_如何学Cng? Or is there a way to merge the info? Thanks, Jose


Core Data lacks concurrency locking so you can't have two apps accessing the same store file at the same time. Core Data isn't a database system but rather an object graph management system that provides the model layer for Model-View-Controller design app. If you try to use it like a database system you will come to grief.

The usually solution to the problem you describe is to create a library directory that contains subdirectories for each instance of the app and put each instance's store in its own dedicated directory so the problem does not occur.

You can build a small server with Core Data that will provide distributed objects to other processes in a reasonably efficient manner. If you have multiple processes that all need the same persistent store, that would be your best bet.

See Marcus S. Zarra's Core Data book for an example of how to do this.

0

精彩评论

暂无评论...
验证码 换一张
取 消