re: Code Data: Re-inserting deleted objects
re: Code Data: Re-inserting deleted objects
- Subject: re: Code Data: Re-inserting deleted objects
- From: Ben Trumbull <email@hidden>
- Date: Mon, 6 Oct 2008 19:10:11 -0700
Chaitanya,
What is the best way to re-insert a deleted object back in to the
managed object context?
-insertObject: will reinsert a deleted object. -insertObject and -
deleteObject will cancel each other out.
Typically, one wouldn't validateForInsert until after reinserting the
object, and then fixing up the relationships. -validateForInsert is
closer in meaning to "can I save (insert into db) this object yet ?"
It's perfectly fine to be in an in between state, as long as you clean
it up before saving.
One more thing, if i directly insert the object without checking it
for validation and then call [A isInserted] it returns NO if i do it
in the same loop, if i do it later, it returns YES, is there anything
special i need to do so that the isInserted flag would be updated?
If insertObject & deleteObject cancel each other out, then -isInsert
will return NO, since the deletion was effectively canceled, and you
won't be saving either the insert or delete to the database.
Basically, you returned to a neutral state.
- Ben
_______________________________________________
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