I don't know if all those tests are necessary. I did show the method to a Core
Data engineer at WWDC one year and he thought it looked OK.
Those are good points about -prepareForDeletion. I was just experimenting for
the heck of it. I guess if it ain't broke I shouldn't fix it. :)
On Oct 22,
Hi Jerry,
On 21 Oct 11, at 2:53pm, cocoa-dev-requ...@lists.apple.com wrote:
In other words, they should have named that method -isDeletedForSure, to
indicate that the NO result is not reliable.
Funny.
Anyhow, today I fixed a problem by using this instead
BOOL isDeleted ;
isDeleted =
This is what I have used for years with good success:
- (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
On 2011-10-21, at 11:57 AM, David Riggle wrote:
I'm currently experimenting with the following to see if it's as safe and
perhaps faster:
- (void)prepareForDeletion
{
// track object deletion for faster testing below
NSString *objIDStr = [[[self objectID] URIRepresentation]
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
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
Ooh, I had never noticed that - I just assumed that the method did what you
would think. That may be the cause of an issue in my code. Thanks for the heads
up.
I would tend to try to avoid processPendingChanges if possible since it appears
to be a rather expensive operation.
Regards
Gideon
On Oct 20, 2011, at 15: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