Open tonyarnold opened 12 years ago
I'd be all for this, and maybe it'd be a good addition to the save methods that have callbacks. My only concern is with the private parent contexts, like for iCloud and TICoreDataSync, which may not respond well to having save called. But otherwise I think it's great and I'll add it soon.
Is there any way to detect that a parent context is being used for iCloud? (TICoreDataSync
is easy enough to detect because of the NSManagedObjectContext
subclass they use).
A cursory glance at a Core Data class dump indicates that their private one is just a plain old NSManagedObjectContext, which complicates things as we don't want to set off any Apple private method checkers. The Ubiquity stuff just subscribes to a ton of notifications on that context.
Would it be acceptable for this to be an extension to -saveWithErrorHandler:
? So that it's something like -saveRecursive:success:failure:
? This is inline with Apple's policy of matching up the most simple method (here, -save
) with a big kahuna that has all the parameters.
Yeah, absolutely. That makes a lot of sense! Good call :)
Presently (and rightly) the save methods only save the context they are called on. However a common scenario is to want to save the changes up through any parents and persist the saved changes to disk. To that end, it would be useful to have a simple method that tracks back through any parents of the current context and saves them all in sequence, like so: