Re: "Dangling reference to an invalid object"
Re: "Dangling reference to an invalid object"
- Subject: Re: "Dangling reference to an invalid object"
- From: Mike Abdullah <email@hidden>
- Date: Tue, 04 Dec 2012 20:25:25 +0000
On 3 Dec 2012, at 18:13, Nick Zitzmann <email@hidden> wrote:
>
> On Dec 1, 2012, at 10:33 AM, Mike Abdullah <email@hidden> wrote:
>
>> I've been trying to hunt down a problem where Core Data will occasionally refuse to save with the error "
>> Dangling reference to an invalid object". I wrote up the details here: http://www.mikeabdullah.net/dangling-ref-to-an-invalid-object.html
>>
>> Can anyone shed some light on how this might happen?
>
> This exception happens if you:
>
> 1. Create a new object
> 2. Create a relationship between the new object and an existing object
> 3. Turn the new object into a fault before it is officially inserted
> 4. Save changes
>
> So if you're getting this exception, you need to be more careful about using the -refreshObject:mergeChanges: method, because the code is most likely misusing it. One way to fix this is to never refresh an object that has a temporary object ID.
Hmmm, we're never calling -refreshObject:… ourselves. Possibly some bit of the frameworks might be, but you'd hope they're not doing anything wrong like that.
Also, I neglected to mention in the blog post, that the TextBoxBody object is created as a consequence of creating and inserting a TextBox object. So I still suspect that the TextBox is being deleted from the context, but somehow failing to take the Body with it.
From my code it seems impossible that inserting the TextBox could somehow fail, but still succeed at inserting the corresponding Body. Thanks for giving me an extra idea of what to check though!
_______________________________________________
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