So, I'm starting to learn how to use Cocoa. I think I did it, but I'm stuck on creating and switching views. I am rewriting a game that I made a little back for practice. All I want is a single window (preferably not resizable), and I want to be able to turn off views for different screens in the game.
Firstly, I have a main menu ("Start the game", "High scores", "Exit"). Then I need a window for each screen (gameplay screen, Highscore screen).
I am embarrassed about how to do this. I searched for NSViewController, thinking that it controls the views, but it is not. It controls only one view, actually loading it. I do not understand why I will need to use NSViewController. Could I just have a window class that contains several subclasses of NSView and load them like that? I'm not sure I understand the purpose of ViewController.
Do I really need the Window class to subclass NSWindowController? I tried to follow the example of the Apple ViewController example, and it has a window controller class, which is a subclass of NSWindowController. I do not understand what the purpose of subclassification is. Everything seems to add NSWindowController - initWithPath:(NSString *)newPath , but I don't see its use when I can simply edit the plist file to open the window at startup. Example Apple also has an NSView variable and an NSViewController variable. You do not need only one variable to store the current view?
Thanks in advance guys, I'm really confused about how this works.
objective-c cocoa nsviewcontroller macos
David garcia
source share