Re: Cocoa-dev Digest, Vol 10, Issue 12
Re: Cocoa-dev Digest, Vol 10, Issue 12
- Subject: Re: Cocoa-dev Digest, Vol 10, Issue 12
- From: Francisco Garza <email@hidden>
- Date: Sun, 06 Jan 2013 14:25:07 -0600
> I have an app which presents folders and files in a tree structure. I'm using an NSTreeController and core data to keep track of the relationships between the files and folders. The ProjectItem entity has a 'children' relationship which is to-many with the same entity and a 'parent' relationship which is to-one with the same entity. The 'children' relationship has a cascade delete rule; the parent one has a nullify rule. I use a tree-controller and then an outline view to display. Pretty normal stuff so far.
>
> I received a bug report from a user saying that when he deletes a folder which contains one or more files then he can't save the document (this is an NSPersistentDocument app, by the way). The error in the logs is
>
> CoreData could not fulfil a fault for <.... Folder/ ...>
>
> I struggled to reproduce this until I did some testing on 10.6.8. There I can reproduce the problem easily.
I've run into this bug before with NSArrayController -- basically the item is selected, you delete it, then the NSTreeControllers/NSArrayController maintains the selection and tries to access the object afterwards for some reason, but the object is deleted and on 10.6 that throws an exception.
Obviously they fixed it in 10.7, but I found the workaround was to set the array/tree controller's selection to empty BEFORE deleting the object. This ensures that it won't get accessed. You can also manually remove the item (by calling removeObject:) then call deleteObject:, which fixes the bug as well.
–F.G.
_______________________________________________
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