I’m been an iphone developer for a couple of years and trying to learn mac os x programming.
The app is very simple. The flow is like the Finder app. A NSTableView on the left, and a “body” view to the right, which will load in different view controllers after the cell have been selected in the tableView.
So I have a main view, and in it, two NSView.
I’m trying to figure out how to load the different viewcontroller in the right view after a cell has been selected in the left view.
I’ve created AppController.h class that controlls the mainview.
My first thought was to make the AppController a singleton and have the left view call a method in that class. Something like this:
- (void)changeViewControllerInRightView:(int)whichView;
But since I’m building the app in interface builder, and put the AppController as a NSObject, I’m not quite sure how to work it out with the singleton.
What is the flow to do this?
Thanks in advance
Save your instance in your App Delegate’s property. And the app delegate instance is such a singleton.
First create an IBOutlet in your app delegate for your AppController instance. Then connect your AppController from Interface Builder(Right click on the AppController, drag ‘New Referencing Outlet’) to this IBOutlet property line in the header file( usually shown in Assistant Editor, and drag-and-drop can help you create the property if not existed yet).