Reputation: 2258
If I have a strong reference to a ManagedObject, and then that ManagedObject gets deleted from the Context, will my strong reference to the ManagedObject still be valid?
Upvotes: 2
Views: 203
Reputation: 57178
Yes, though if your managed object is a fault (either because you've never accessed any values in it, or because you've turned it back into a fault with refreshObject:mergeChanges:
) then if you try to access any properties on your deleted object, it will throw an exception.
So, you should be careful to check for isDeleted or else listen for notifications (e.g. NSManagedObjectDidSaveNotification) and check to see if your object was deleted.
Upvotes: 2
Reputation: 50109
yes it will be valid. it should reflect that it is deleted. object.isDeleted
Upvotes: 1