Dynamically loading a part of a Window in Cocoa

cocoa, interface-builder, nsview, objective-c

Solution

In modern Cocoa, this is the job of view controllers. Cathy Shive has some good blog posts about them (1, 2, 3), and co-authored a more useful view controller class than the basic NSViewController.

Problem

I have an area of a Window (in my MainMenu.xib) which I'd like to populate dynamically with unrelated "views" such as an NSTable, IKImageBrowserView etc. at different points of time depending on some user-selected criteria. - How do I define this area of the window such that it can be "replaced" with different views? - How do I attach a table or some other view to this area of the window? (Is it enough to place a generic NSView there and add a subview each time? I'm fairly new to Cocoa, so any pointers are welcome)

Original source