Core Data: Multiple stores: saving problems
Core Data: Multiple stores: saving problems
- Subject: Core Data: Multiple stores: saving problems
- From: Jonathan Fewtrell <email@hidden>
- Date: Sat, 10 Jul 2010 19:10:52 +0800
I am developing a Core Data iOS app that accesses static data from a read-only sqlite store in the app bundle and also saves user data (comments, ratings, etc) in a separate sqlite store in the application documents directory.
The 'UserData' entity is assigned to one configuration ("UserDataReadWriteConfig"), and all the static data entities to another ("StaticDataReadOnlyConfig").
Problem is that when I come to save the context, i get the message NSUnderlyingException = "Cannot update objects into a read only store." and this message is given in relation to an entity that is in the StaticDataReadOnlyConfig configuration. The NSPersistentStoreCoordinator has been told that the store for that configuration is read-only, so why is it even trying to update objects?
It is true that objects of one of the 'read-only' entities (called FWItem) can have changes in the sense that a relationship can be created with a UserData object. But this is a transient property, so I don't see why this should impact the saving process.
Can anyone enlighten me?
I have the feeling that it may be something to do with the fact that I have a cross-store relationship, namely a one-to-one relationship between FWItem and UserData. This is transient. At save time, I try to save UserData's -fwItem relationship into a URI binary data attribute. I'm trying to base this on the iClass sample project. I note that iClass seems to have disappeared from the latest tools, and I was hoping another example of cross-store relationship handling had replaced it, but I can't see one. Is the iClass approach no longer approved?
The other point causing me consternation is that -willSave is apparently not called on my managed objects. In other words, after I call -save: on the context, the above error message is given BEFORE -willSave has been called. This seems odd. I need -willSave to be called first so I can configure the objects to deal with the cross-store relationship. Any insight appreciated.
_______________________________________________
Cocoa-dev mailing list (email@hidden)
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:
This email sent to email@hidden