KVO and lazy loading
KVO and lazy loading
- Subject: KVO and lazy loading
- From: Ashley Clark <email@hidden>
- Date: Tue, 21 Oct 2008 02:23:55 -0500
I'm pretty sure I've got this worked out and it seems to be working,
BUT I thought that before and when I turned on Auto Arrange Content on
my NSArrayController's this bug popped up. So I wanted to make sure
I'm doing this right.
I'm lazily initializing objects that are being read from a database,
similar to CoreData faulting. In my RMDatabaseObject class I've
implemented a willAccessValueForKey: method that reads in data from
the database if necessary. This method is being called at the
beginning of my willChangeValueForKey: and
willChangeValueForKey:withSetMutation:usingObjects: methods.
Originally, for every property that was being set through the
willAccessValue method I was calling the willChange/didChange methods
and it seemed to work well. At least until I turned on auto-arrange
content on some array controllers. After that I started getting
exceptions stating that observer's were being removed more times than
they had been added on seemingly random key paths.
I finally found a comment by mmalc and seconded by Ronzilla at http://theocacao.com/comment/4423
that seems to indicate that one should NEVER post change
notifications when doing this sort of lazy-loading.
So, after all that, my question is this, is this correct? Or will I
run up against something else later if I'm not issuing change
notifications during my initial database row loading?
Ashley
_______________________________________________
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