开发者

NSView inside self window

I h开发者_StackOverflow社区ave 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?


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.


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, it's available on Stanford iTunes (iTunes link), iPhone SDK share the same underground with the OSX SDK so it's exactly the same for ViewControllers.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜