Re: Cococa-Dev : was [coredata count not fulfill fault after object delete]
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: Mike Abdullah <email@hidden>
- Date: Mon, 07 Jan 2013 19:44:34 +0000
On 7 Jan 2013, at 16:35, Martin Hewitson <email@hidden> wrote:
> 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?
Why are you calling -processPendingChanges at each iteration of the loop? Calling it yourself is rarely needed, and best done only with justification.
_______________________________________________
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