On 20 Oct 2011, at 23: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.
The problem here is that Core Data's definition of "deleted" is a little
different to what you'd' expect:
Expected:
-[NSManagedObjectContext deleteObject:] has been called with the
object, and that deletion hasn't been undone
Actual:
The object is listed under -[NSManagedObjectContext deletedObjects].
i.e. the object has been marked for removal from the parent store/context, next
time the context is saved.
_______________________________________________
Cocoa-dev mailing list ([email protected])
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 [email protected]