Skip to content
This repository has been archived by the owner on Sep 12, 2018. It is now read-only.

Save Only the Object #92

Open
matrinox opened this issue Apr 2, 2014 · 3 comments
Open

Save Only the Object #92

matrinox opened this issue Apr 2, 2014 · 3 comments

Comments

@matrinox
Copy link

matrinox commented Apr 2, 2014

This can be achieved by having exactly one MOC per object but I'm not sure of the implications in both using it and coding it. Would there be huge memory implications? Would this have to be a special condition, like fetching an object with a hasOwnManagedObjectContext flag set to yes? Are there alternatives to this, perhaps when calling save creating a child MOC, saving that, and merging back into the original MOC?

@stephencelis
Copy link
Collaborator

Hm, could you please provide more information on some examples of why you'd want to do that in your application?

I actually wonder if it makes more sense to remove the -save method entirely, as it's confusing right now (and obj.managedObjectContext save: is not too difficult to remember/type).

An alternative might be the idea of block-based transactions, where updates that happen in the block are done on a new child context, and when the block completes it saves the context, then merges it back into the main context.

@supermarin
Copy link
Owner

@stephencelis given the path of decoupling from CoreData, i'd still keep this one in.

@matrinox
Copy link
Author

matrinox commented Apr 2, 2014

The example I can think of is saving a nested attribute without saving the parent (e.g. saving contacts without saving profile).

Block transactions seems like a good implementation.

Also I agree that current -save is misleading and really just a shorthand. That's why I think it's a great use for individual object saving.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants