views:

166

answers:

2

I'm trying to figure out how to create a view that, depending on the circumstances, has a variable number of items being displayed in it. Something like the grid view in Finder or iTunes, an image with a sort of caption text underneath it. I've heard that you can use an NSCollectionView for this sort of thing, but I don't really know. I'm sort of a programming n00b, so any help is appreciated.

A: 

Yes, that is exactly what NSCollectionView is for. For a list view, NSTableView or NSOutlineView. For column view, NSBrowser.

For more information, see the Application Kit Framework Reference.

Peter Hosey
+1  A: 

NSCollectionView is one way to go, it's basically a collection of subviews. IKImageBrowserView is another class you should take a look at, it's a ready made icon view similar to iPhoto.

The simplest way would be to create your own NSView subclass, and in drawRect: just draw your items one by one until you reach the bounding area of your view. If you need a full featured UI object with selection, reordering, or anything else it's probably best to look at one of the existing classes though, since it'll be a lot of work to do all that yourself.

Marc Charbonneau