Re: Binding of invisible controls: is lazy data loading possible?
Re: Binding of invisible controls: is lazy data loading possible?
- Subject: Re: Binding of invisible controls: is lazy data loading possible?
- From: Quincey Morris <email@hidden>
- Date: Mon, 19 Jan 2009 13:27:18 -0800
On Jan 19, 2009, at 12:11, Vitaly Ovchinnikov wrote:
I cache those data, but when I change something that affects them, I
need to reset the cache. And to let everyone know that something
changed, I call -will/didChangeValueForKey for my property. And
controller immediately call this property even if grid is not visible.
This sounds like the relevant issue. If you call will/
didChangeValueForKey for a *collection* property, observers of the
property (the array controller and, indirectly, the grid, in this
case) must assume that everything has changed.
The solution is to *not* call will/didChangeValueForKey, which often
indicates a poor coding solution anyway. Instead, update your data
model KVO compliantly. This means:
1. If some change affects a cached object's properties, update it KVO
compliantly. (Use setters to change its properties, or use
keyPathsForValuesAffecting<Key> class methods to indicate which keys
its properties depend on, and update *those* keys KVO compliantly.)
2. If some change affects which objects are cached, update the cache
array KVO-compliantly. (Use standard NSMutableArray methods on
[yourCacheOwner mutableArrayValueForKey: @"yourCacheArray"] instead of
yourCacheArray.) That will let the array controller know just what
changed, and allow it to be selective about what it queries as a result.
_______________________________________________
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