Skip navigation.
 
mlNSCollectionView questions
FROM : Dave Hayden
DATE : Wed Feb 06 23:07:16 2008

I've finally had a chance to play around with NSCollectionView--pretty 
handy, but a few things are still giving me trouble:

As far as I can tell, IBOutlet connections from collection item 
subclasses or the prototype view aren't preserved. NSControl target/
action links from the prototype view's contents to the collection item 
DO work, which makes me think I need to do something in copyWithZone 
or the like, but I haven't found the right magic. The only workaround 
I've been able to come up with is giving the view a reference to the 
collection item in setRepresentedObject:, then the view's contents can 
get at the item through their superview. Ick.

I'm loading some 3,000 items into the list, and it's pretty slow. 
Sampler says that the first third or so of that is setting up bindings 
for the copied views. In this case the underlying data won't be 
changing, so I could set up the views by hand in the collection item's 
setRepresentedObject: method--but not without those IBOutlet 
connections.. (The middle third is looking for button cells or 
something, -[NSView _recursiveFindDefaultButtonCell]. Out of my hands, 
I'd guess, if I want to have a button in the view.) The last third 
appears to be setting up the animation, which I really don't need in 
this case (or even notice--the contents appear instantly). Is this 
avoidable?

Another odd thing I've noticed is that adding an item to the model 
array causes the entire collection view to reload. (And at first, I 
was using [[self mutableArrayValueForKey:@"items"] 
addObjectsFromArray:] which appears to insert the objects one by one 
instead of in a batch: adding 3,000 items would allocate around 4.5 
million views!) I'd like to prepare data on a worker thread and feed 
it in batches to the main thread to display in the collection view, 
but this isn't really feasible if the view rebuilds itself from 
scratch every time. Is that how it's supposed to work? Or have I 
bungled something up?

Thanks!

-Dave
Panic, Inc.

Related mailsAuthorDate
mlNSCollectionView questions Dave Hayden Feb 6, 23:07
mlRe: NSCollectionView questions Dave Hayden Feb 9, 00:04
mlRe: NSCollectionView questions Carter R. Harrison Feb 9, 00:54
mlRe: NSCollectionView questions David Carlisle Feb 11, 23:59
mlRe: NSCollectionView questions Adhamh Findlay Feb 12, 00:15
mlRe: NSCollectionView questions David Carlisle Feb 12, 06:47
mlRe: NSCollectionView questions Dave Hayden Feb 12, 23:02
mlRe: NSCollectionView questions David Carlisle Feb 13, 00:05