Re: HELP!! Big problem with relationships and saving in iOS core data
Re: HELP!! Big problem with relationships and saving in iOS core data
- Subject: Re: HELP!! Big problem with relationships and saving in iOS core data
- From: Keary Suska <email@hidden>
- Date: Thu, 01 Mar 2012 12:57:28 -0700
On Mar 1, 2012, at 7:12 AM, Eric Giguere wrote:
> I'm on the verge of loosing my sanity... I've been running after save bugs and I'm now completely out of ideas, other than to drop Core Data.
>
> In my model, I have EntityA, wich has an 1-many relationship to EntityB, which also have a 1-many relationship to EntityC.
> Both relationship are bi-directionnal, and I'm using cascade delete from A to C.
>
> The only object in that chain that seems to be deletable is EntityB.
> As soon as I try to delete an object from EntityC (A -> B -> C), I get this error:
> Terminating app due to uncaught exception 'NSObjectInaccessibleException', reason: 'CoreData could not fulfill a fault for
>
> I've been hitting this error for a long time now. I've read that it may be because I may have a reference in my code to the object that get deleted. So I cleaned up everything, nothing does.
> So out of despair, I've created a small method in my main window that creates a new tree of object (A contain 1 B, contains 1 C) and try to delete C. No references anywhere here.
>
> If I try deleting the C object before saving the new stuff, I get this error:
> Domain=NSCocoaErrorDomain Code=134030 "The operation couldn’t be completed. (Cocoa error 134030.)
> NSUnderlyingException = "Cannot update object that was never inserted.";
>
> And if I save, then delete then save again I get back to the NSObjectInaccessibleException.
>
>
> Anybody, please, if you have a pointer so that I could find and fix this error... It does not make sense that such a library fails with such a trivial case.
> I must be doing something wrong, but I've re-re-re check everything and don't see.
>
> I've played with the reverse relationship delete rules, made all of the optional, put them to nil before saving, nothing does :(
There may not be enough information here but I take a shot. Are you suing only one managed object context? Multiple contexts do *not* automatically sync, so if you don't handle this yourself you will run into similar problems. Does C have any relationship to A? Is C loaded directly or through B, and B likewise trough A? Or, if all objects are new, are you properly adding each object to the relationship (that also doesn't happen automatically, although properly bound NSArrayControllers will do this for you)?
HTH,
Keary Suska
Esoteritech, Inc.
"Demystifying technology for your home or business"
_______________________________________________
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