On 2011 Oct 21, at 08:57, David Riggle wrote:

> - (BOOL)retainedObjectHasBeenDeleted
> {
>       // if object has been deleted, then it no longer exists
>       if ([self isDeleted]) return YES;       
>       // otherwise, see if object with this ID exists in the database
>       NSManagedObjectContext *context = [self managedObjectContext];
>       if (context == nil) return YES;
>       NSManagedObjectID *objectID = [self objectID];
>       if (objectID == nil) return YES;
>       NSManagedObject *obj = [context objectRegisteredForID:objectID];
>       return obj == nil;
> }

Interesting, David.

Why do you check for the object ID?  Have you ever seen an object which passed 
the first two tests (not isDeleted, has MOC), but then didn't have an objectID? 
 How could that happen?

> I'm currently experimenting with the following to see if it's as safe and 
> perhaps faster…

Are you having performance issues with your original 
-retainedObjectHasBeenDeleted?  

In my world, -retainedObjectHasBeenDeleted is only going to be invoked in 
corner cases, but documentation states that -prepareForDeletion is invoked 
"when the receiver is about to be deleted".  That may be quite often in some 
use cases.  Also, there is another definition trap there – what does "when the 
receiver is about to be deleted" mean?  How will that be interpreted by an 
Apple engineer who adds some new object-deleting method to support iCloud 2.0 
in Mac OS 10.8?  Plus, what Dave Fernandes noted.

I think that your original -retainedObjectHasBeenDeleted is fine and I wouldn't 
mess with it if I were you.

_______________________________________________

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

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:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Reply via email to