After I finished reading the book and working through the exercises, reading some of Apple’s example programs and trying to write some good small example programs myself, I am well aware that I still have much to learn. One crucial matter is how to structure (factor) Cocoa programs in a good, standard, way. I’ve seen the thread “Am I missing something?” started by drtyrell, and I think I understand what [s]he is trying to say, but have a follow-on question. This is: it is, I’m sure, good practice to have a separate instance of a subclass of NSViewController to manage each complicated view in a program, but how exactly to code that in the best way? (There are hints elsewhere on the web, but I think the book should cover this.) A complicated view might never move from its initial position in the document window, so we’re not talking about view swapping.
The Chapter 12 example - “Adding a panel to the application” - introduces an AppController (a term not found in the book’s index) and a window with its own instance of an NSWindowController. Chapter 31, "View Swapping’, would be better - IMHO - if it was preceded by an example of adding a view to the window (with controls/subviews as needed) which was managed by its own instance of an NSViewController. I’d like to see how best to combine the program’s subclass of NSDocument, the AppController, the complicated view’s instance of the NSViewController and the complicated view. Instead, we leap in 31 straight into the more specialised situation of alternate views presented in an NSBox owned by the document, and the AppController has vanished - so, how to combine the ideas of Chapters 12 and 31?
Chapter 30 - “Developing for iOS” - has more on alternate (UI) View Controller instances controlling separate views, there being no NSWindowControllers for iOS. Perhaps the idea of separate view controllers for complicated OS X views could be introduced before that, and the iOS chapter be made optional?
Can anyone recommend a really simple (short!) but complete example bit of code of good practice for what I want to do?