Re: KVO and Core data
Re: KVO and Core data
- Subject: Re: KVO and Core data
- From: Gideon King <email@hidden>
- Date: Tue, 10 Aug 2010 01:13:37 +1000
Thanks Keary and Dave
Yes, Ben helped me a lot with sorting out the underlying issues, which turned out to be a number of misunderstandings about what various methods in the atomic store are supposed to do, what is required, etc etc. And at the time, we had got to a point where we could save, save as, open and save, and it all worked, but this is the first time we have revisited the whole file saving thing after making a bunch of changes to the model and lots of KVO stuff, and either there were inherent problems that we didn't see before because we weren't observing attributes like this, or we may have introduced issues that weren't there before.
Dave's idea of using + (NSSet*)keyPathsForValuesAffecting<Key> may help in some situations, but I don't think it's practical for all, especially where I'm using KVO for my front end to observe changes in the back end and react, where I sometimes need to know the before and after values. I'd have to think about that some more...
I hadn't thought about the faulting and refetching issue, and I do need to support 10.5, so don't have the awakeFromSnapshotEvents available to me.
So, still a little uncertain on the best solution for my situation...
Regards
Gideon
On 10/08/2010, at 12:20 AM, Keary Suska wrote:
>
> The trace shows that the destination has been invalidated before your object is faulted, and so the exception is raised when it tries to remove observation. Invalidated object references should be rare--I would expect Core Data to "clean up" relationships when a MOC is reset but that does not appear to be the case (at least not all the time). Have you re-looked at the issues around the question you asked back in April: http://www.cocoabuilder.com/archive/cocoa/284398-invalidated-managed-objects.html ?
>
> If that doesn't help, the easiest workaround I can think of is have the destination observe its attribute, and then call a method on all objects from the inverse to-many.
>
>> So I have two questions:
>>
>> 1. Is it the "right way" for me to be adding observation on the awake methods and removing it on willTurnToFault?
>
> For cross-relationship KVO, generally yes.
>
> Keary Suska
> Esoteritech, Inc.
> "Demystifying technology for your home or business"
>
_______________________________________________
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