I usually don't use interface builder but from what I have gather it seems that interface builder if mostly for building self contained window. Is it possible to create a view with IB and then import this NIB file and use it as a subview?
Yes. One of the templates is for a stand-alone view. If you have a nib already, you can drag any view from the Library panel into it.
To add what Peter wrote: Yes you can, and it's also a fairly common method. For example, since 10.5 there's a class called NSViewController
which does just that, and the interface builder has a template for that, too.
The steps are:
- Create a view in the nib file.
- Connect it to an outlet of the File's Owner.
- Load a nib, supplying the file's owner. If you use
NSViewController
, it's done by-initWithNibName:bundle:
. In this case, the view is set at[self view]
. - There's no step 4.
Slightly off topic, but I think it's worth spending some time for you to learn a bit of Objective-C and Cocoa program using it, before directly delving into the world of Cocoa bridges to other languages, be it RubyCocoa, PyObjC, or clozure-CL. That's because almost all of the Cocoa documentation, blog posts etc. is written for Objective-C. Objective-C is not a difficult language to learn, especially if you know OO and C already.