I\'d like to start a Cocoa app with a ViewController
just like the iOS \"Single View App\" template, but there is no such template (is there a public / open source
On OS X NSViewController
isn't as often used as UIViewController
on iOS. One of the reasons is that it's not really useful and lacks a lot of the nice features of UIViewController
. There are only a couple of situations where you really have to use them, like when using an NSPopover.
There are several ways to structure your OS X code. One of them is using NSWindowController. You can think of NSWindowController
as the equivalent of UIViewController
on iOS.
The "Controller" in OS X with respect to managing NSViews is the NSWindowController
. Though Drummer says that NSViewController
isn't very useful, I must disagree - it is useful for splitting up your NSWindowController
once it gets too large, and has clear logical divisions in terms of views.
You could have one NSWindowController
, and once it gets complicated enough, the NSWindowController
could delegate tasks corresponding to specific views to subclasses of NSViewController
, and in that respect it is very useful.
In the default templates (if I remember correctly) the AppDelegate
takes the role of the window controller, though it isn't technically one. In more complex applications it is a good idea to instantiate a window controller instead.
As long as you don't mix up the controller and view anything can be used. The View should be relegated to just display and basic input handling.