• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Cococa-Dev : was [coredata count not fulfill fault after object delete]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Cococa-Dev : was [coredata count not fulfill fault after object delete]


  • Subject: Re: Cococa-Dev : was [coredata count not fulfill fault after object delete]
  • From: Martin Hewitson <email@hidden>
  • Date: Mon, 07 Jan 2013 17:35:18 +0100

Hi Francisco,

Thanks for the feedback!

What you suggest sounds like it might fix the problem, but I'm wondering how best to do this. Currently I'm just calling -remove: on the tree controller to delete the selected object(s). Of course, if I clear the selection first, then -remove: doesn't do anything. I can grab an array of the selected objects before clearing the selection then use NSManagedObjectContext's -deleteObject:. So something like this:

    // get a pointer to the selected items
    NSArray *items = [self selectedObjects];

    // clear selection
    [self setSelectionIndexPaths:@[]];

    // now delete from the MOC
    for (NSManagedObject *item in items) {
      [self.managedObjectContext deleteObject:item];
      [self.managedObjectContext processPendingChanges];
    }

Does that look sensible to you?

Best wishes,

Martin

On 6, Jan, 2013, at 09:27 PM, Francisco Garza <email@hidden> wrote:

> Sorry, trying to respond to your message but goddamn Apple Mail...
>
>
>> 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'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


  • Follow-Ups:
    • Re: Cococa-Dev : was [coredata count not fulfill fault after object delete]
      • From: Mike Abdullah <email@hidden>
  • Prev by Date: Re: PDFView drawPage called often after selecting text
  • Next by Date: Re: PDFView drawPage called often after selecting text
  • Previous by thread: Re: PDFView drawPage called often after selecting text
  • Next by thread: Re: Cococa-Dev : was [coredata count not fulfill fault after object delete]
  • Index(es):
    • Date
    • Thread