Hi List,
What is the best way to re-insert a deleted object back in to the managed object context?
At present i'm trying to this:

if ([objectToReinstate validateForInsert:&error])
 [[self managedObjectContext] insertObject:objectToReinstate];

But i am having problems with objects having relationships, suppose i have entities A,B and C having relationships as: A<--->B<--->C All the relationships are mandatory (i.e the optional flag is unchecked) also the delete rule for A--->B and B--->C is Cascade .

Now suppose i delete A, due to the cascade rule B and C will also get deleted. Now if i want to reinsert all of them in to the MOC, i kinda have a deadlock situation

If i do this:
if ([A validateForInsert:&error])
 [[self managedObjectContext] A];

It will not work because to reinsert A needs a valid relationship with B which in this case will be nil.
i cannot re insert B either because i haven't inserted A and so on.

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?

I' appreciate any help.
thanks,
Chaitanya


_______________________________________________

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

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:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to [EMAIL PROTECTED]

Reply via email to