Re: Core Data: Determine if managed object is deleted
Re: Core Data: Determine if managed object is deleted
- Subject: Re: Core Data: Determine if managed object is deleted
- From: Gideon King <email@hidden>
- Date: Fri, 21 Oct 2011 09:07:45 +1000
Ooh, I had never noticed that - I just assumed that the method did what you would think. That may be the cause of an issue in my code. Thanks for the heads up.
I would tend to try to avoid processPendingChanges if possible since it appears to be a rather expensive operation.
Regards
Gideon
On 21/10/2011, at 8:37 AM, Jerry Krinock wrote:
> When I need to know whether or not a managed object is deleted, often I fall into the trap of trying -[NSManagedObject isDeleted], forgetting that its documentation states …
>
> "… It may return NO at other times, particularly after the object has been deleted. …"
>
> In other words, they should have named that method -isDeletedForSure, to indicate that the NO result is not reliable.
>
> Anyhow, today I fixed a problem by using this instead …
>
> BOOL isDeleted ;
> isDeleted = [object isDeleted] || ([object managedObjectContext] == nil) ;
>
> I'm not sure if it will work in all situations. I suppose that sending the magical -processPendingChanges would be another workaround.
>
_______________________________________________
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