• 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: Core Data: Determine if managed object is deleted
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Core Data: Determine if managed object is deleted


  • Subject: Re: Core Data: Determine if managed object is deleted
  • From: Quincey Morris <email@hidden>
  • Date: Thu, 20 Oct 2011 17:27:57 -0700

On Oct 20, 2011, at 15:37 , 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.

FWIW, I also wonder if this ("Is it deleted?") is the right question to ask. As you've documented here, the technical question is largely a housekeeping one -- about how the object is represented in terms of the in-memory object graph vs the persistent store, faulting, etc.

Functionally, isn't the question likely to be whether the object is … I dunno … *reachable* any more? From that point of view, the criterion may well be whether a key relationship of the object is null or not.

IOW, it's a question of the object's role, not its representation, and the Core Data representation isn't conclusive as to the role.

It's just a thought. You seem to have been chasing these representation-related deletion issues for months now, or longer.


_______________________________________________

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

References: 
 >Core Data: Determine if managed object is deleted (From: Jerry Krinock <email@hidden>)

  • Prev by Date: Re: Core Data: Determine if managed object is deleted
  • Next by Date: Re: ARC + return of autoreleased CFType
  • Previous by thread: Re: Core Data: Determine if managed object is deleted
  • Next by thread: Re: Core Data: Determine if managed object is deleted
  • Index(es):
    • Date
    • Thread