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

Core Data: Determine if managed object is deleted


  • Subject: Core Data: Determine if managed object is deleted
  • From: Jerry Krinock <email@hidden>
  • Date: Thu, 20 Oct 2011 15:37:50 -0700

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

  • Follow-Ups:
    • Re: Core Data: Determine if managed object is deleted
      • From: Mike Abdullah <email@hidden>
    • Re: Core Data: Determine if managed object is deleted
      • From: Quincey Morris <email@hidden>
    • Re: Core Data: Determine if managed object is deleted
      • From: Gideon King <email@hidden>
  • Prev by Date: Re: ARC + return of autoreleased CFType
  • Next by Date: Re: ARC + return of autoreleased CFType
  • Previous by thread: Re: WebView doesn't scroll
  • Next by thread: Re: Core Data: Determine if managed object is deleted
  • Index(es):
    • Date
    • Thread