Thank you Greg.
Now i know it can be done.
much appreciated!

Sandro.


On 2010-06-07, at 11:46 AM, Greg Reichow wrote:

> 
>> Greetings.
>> 
>> I'm building a iPhone application which is database driven.
>> in that application i've designed it to have two databases.
>> One database will be distributed with the application and is meant to be 
>> read only.
>> the second database is meant to copy items to it for the user's safe keeping.
>> 
>> the reason for this is that the application update will also include a 
>> refreshed database
>> and as such if i only link to the records it might happen that the record 
>> that the user 
>> wished to keep would of been purged from the original database.
>> 
>> evidently the structure is quite the same on both, with the exception of 
>> some additional fields
>> in the user database.
>> 
>> when the application starts it complains that it can not merge the two 
>> models.
>> i've been looking on the net but found nothing of significance.
>> 
>> is it possible to have two separate database in the same application on the 
>> iphone.
>> and what are the steps to make it happen.
>> 
>> do i have to duplicate the Core data initialization procedures and maintain 
>> 2 distinct managed object contexts?
> 
> I have a very similar application requirement.  In my case, I am using 2 
> separate persistent stores.   One is the user store located in their 
> documents directory to maintain their unique copy of the database and edits 
> to the provided data.  The second is part of the application bundle.  In this 
> case, I use 2 separate MOC's and migrate data from the app persistent store 
> to the user persistent store.  Using the metadata that can be stored with the 
> persistent stores, I check a version key I create and then if it is 
> different, do a merge of the 2 stores.  See the core data docs for a method 
> for efficiently doing a large comparison and merge.  This has worked quite 
> well and allows for application database updates without messing up any 
> unique changes the user has made to their own earlier copy.  
> 
> Doing it this way also protects the user if the application is reloaded.  The 
> user data in the documents directory is backed up and can easily be restored.
> 
> As for model changes, if they are simple changes to the model between 
> versions, you may be able to get away with lightweight migration.  It is a 
> simple option to add when loading the persistent store.  
> 
> There very well may be a better approach but this has successfully worked for 
> me.
> 
> Greg Reichow
> MangoCode

_______________________________________________

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Reply via email to