views:

153

answers:

2

I have basic *.xib file, which have NSView.

How can I use another nib files for this Custom View? What is NSViewController and how should I use it?

screen shot

+1  A: 

NSViewController as its name suggests is a Controller class, means it connects the View to the Model, in a perfect MVC environment.

Each ViewController is bound to one View, you can build that view in code or using the Interface Builder.

For more help, i would suggest to watch Stanford University iPhone programming course, its available on Stanford iTunes (iTunes link), iPhone SDK share the same underground with the OSX SDK so its exactly the same for ViewControllers.

medopal
+1  A: 

Generally, you create a new nib, selecting "View" as the nib template. Then you select the File's Owner and set its class to NSViewController (or your own subclass of it, in which case you may have to add the nib to your Xcode project first) in the last tab of the Inspector. Then you connect the view controller's "view" outlet to the view.

You should read Apple's docs on NSViewController, it's actually a very simple class. However, before you start drawing and coding I would suggest you should carefully structure your app in MVC terms. If you make a mistake in the design phase, you will have to redo a lot of your work later. Using view controllers is not always justified, it depends on the complexity of the app.

Costique