I have an array within a model object that is hooked up to a NSCollectionView
via an NSArrayController and NSCollectionViewItem (i.e. standard). The array
elements are custom objects with a title and image property. These are bound
to an NSTextField and NSImageView within the view managed by the
collection-view-item. Hook all the bindings up and go. It works... basically.
Problem: the properties for EVERY element within the array are requested when
the collection view appears on screen. Well, really, I am binding the
collection view to the array controller in code within awakeFromNib and the
trouble happens at the point of binding (thus, I think the ask-for-everything
really happens independent of the appear-on-screen issue). Partial/edited
backtrace:
my call to [collectionview bind:toObject:withKeyPath:options:]
triggers <stuff >
[collectionview setContent:]
[collectionview _getItemsToDisplay]
<more stuff leading to> [array-element image]
I guess "_getItemsToDisplay" does not care about what is actually being
displayed NOW vs. the entirety of what can be displayed.
This was not what I was expecting nor wanting. My experience in the datasource
flavor of NSTableView led me to believe (and be happy about) UI elements not
asking for display data until view/cell associated with said data was truly
on-screen. Perhaps NSTableView is just as greedy about touching every element
once you depend on bindings (but I'm guessing not).
Question: can this behavior be avoided through simple means? I have seen some
related discussions (
http://lists.apple.com/archives/Cocoa-dev/2009/Jan/msg01536.html ) but I
believe the discussed situations (and potential solutions to them) do not cover
my setup (which I think would be a common one). I don't need to build the
array-like structure as I go and, thus, I don't care if some part of bindings
asks for the entire array of content. What I care about is the properties of
the elements in this array being accessed before the associated row appears
on-screen. The image property is calculated on-demand and it is better
performance and memory usage to NOT pre-calculate every image.
Do I have to hack away or can the collection be convinced to operate in this (I
think, obvious/superior) "lazy loading" style?
Thanks in advance.
Mark Sanvitale
Real Networks
_______________________________________________
Cocoa-dev mailing list ([email protected])
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:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com
This email sent to [email protected]