I'm trying to put up a basic app with a tabbed interface, and it's been a few years since I've done any cocoa development so I'm rusty... My app will use tabs, and display a default view of items when you load a tab, allowing you to click on one of the items to swap in a view for that item (think chrome, when you open a new tab and it displays your favorite sites which you can click on to open).
Currently I have implemented a basic single window UI for this almost entirely in interface builder. A window with an NSCollectionView, using bindings with an ArrayController and NSMutableArray of collection items in my window controller. Works great.
There are two things, however, I'm not sure about and it makes me wonder if I'm better off doing things programmatically here instead of messing with Interface Builder. Specifically the two things I'm not sure how to do:
- Get click events on the NSCollectionView and map that to the model the clicked on item represents.
- Load new instances of this collection view in new tabs (a user could open up multiple tabs all of which should display the grid of items)
For #1 I don't really see a great way to do this. I can capture mouseDown in the window controller, but I have no idea how to map that back to the model. I also created a NSView subclass for my collection view item, however I can't figure out a way to map that view to the model either...
For #2 I don't think there's a great way to do this, other than creating the views programmatically. The only other thought I had was to put the view in another .xib and use that to create new views when needed. Which would probably work fine if I could figure out #1...
So, am I better off just creating the collection view programmatically or is there something I can do here?