When does NSManagedObject -managedObjectContext "return null if the receiver is removed from the context"?

The NSManagedObjects method documentation managedObjectContextsays:

This method can return zero if the recipient has been removed from its context.

Does anyone know under what circumstances this method will return nil for a recipient that has been deleted, and under what circumstances will it still return the context of the managed entity?

Background:
I redefine -didSaveto move the files referenced by the remote managed entity to the trash. After that, I need to clear the undo manager because deleting this managed entity can no longer be undone since files cannot be returned from the trash. Therefore, I will call:
 [[[self managedObjectContext] undoManager] removeAllActions];
which will work only if it -managedObjectContextdoes not return nil at this point.

+4
source share
1 answer

Absolutely! There are a number of scenarios where this can happen. The most common is that the application retains a link to NSManagedObjectafter it has been removed from it NSManagedObjectContext.

NSManagedObjectContext NSManagedObject - . . . , . .

+2

All Articles