Note that there are some explanatory texts on larger screens.

plurals
  1. POCoreData design pattern: persisting a single object of many -or-how many NSPessistentObjectContexts should I have?
    primarykey
    data
    text
    <p>I'm converting an app from SQLitePersistentObjects to CoreData.</p> <p>In the app, have a class that I generate many* instances of from an XML file retrieved from my server. The UI can trigger actions that will require me to save <em>some</em>* of those objects until the next invocation of the app.</p> <p>Other than having a single NSManagedObjectContext for each of these objects (shared only with their subservient objects which can include blobs). I can't see a way how I can have fine grained control (i.e. at the object level) over which objects are persisted. If I try and have a single context for all newly created objects, I get an exception when I try to move one of my objects to a new context so I can persist it on ots own. I'm guessing this is because the objects it owns are left in the 'old' context.</p> <p>The other option I see is to have a single context, persist all my objects and then delete the ones I don't need later - this feels like it's going to be hitting the database too much but maybe CoreData does magic.</p> <p>So:</p> <ol> <li>Am I missing something basic about the way my CoreData app should be architected?</li> <li>Is having a context per object a good design pattern?</li> <li>Is there a better way to move objects between contexts to avoid 2?</li> </ol> <p>* where "many" means "tens, maybe hundreds, not thousands" and "some" is at least one order of magnitude less than "many"</p> <p>Also <a href="https://devforums.apple.com/message/78787#78787" rel="nofollow noreferrer">cross posted to the Apple forums</a>.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload