Re: refreshObject throws for object no longer in database
Re: refreshObject throws for object no longer in database
- Subject: Re: refreshObject throws for object no longer in database
- From: Steve Steinitz <email@hidden>
- Date: Mon, 18 May 2009 15:39:01 +1000
Hi
For the archives, I'll comment on my own question.
On 17/5/09, Steve Steinitz wrote:
I've added code to refresh objects from the database store ...
It works well except when another machine has deleted an
object. I've
tried several ways of overcoming the NSObjectInaccessibleException
I found that calling refreshObject with mergeChanges: NO doesn't
cause that exception, nor any other, faulting the object as it
does. However, if I use mergeChanges: NO on all the objects
that meet my criteria for remote change I lose some of the
user's in-memory changes. So, I now compare the object's
modificationDate to the last save date (time). If its newer I
use mergeChanges: YES, if older I use mergeChanges: NO.
For a reason that I don't yet fully grasp, I had to use
primitiveValueForKey to access the object's modificationDate or
else it didn't give the desired result. Perhaps it's to do with
the evil manner in which I set the modification date: in a
custom, global superclass's didChangeValueForKey. I note that,
re the Apple Docs, I am "strongly discouraged from overriding"
didChange. A worry...
In any case, so far, its working well, even if two machines
delete the same chunk of object graph, and, in other previously
troublesome scenarios. I can conceive of scenarios where it
might still throw but they are sufficiently perverse that an
exception may well be the best outcome.
Cheers,
Steve
_______________________________________________
Cocoa-dev mailing list (email@hidden)
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:
This email sent to email@hidden