Hi, I have asked this question several times, but without a definite answer, so I created it for xcode 7 and swift2 (which may have changed the situation a bit).
I created a project using Xcode 7 and the Cocoa OSX Story + swift2 plugins, so my project started with NSWindowController , which connects to NSViewController (as expected!). I added NSToolbar to my window controller and added NSButton to the toolbar. I changed my NSViewController to one of the new NSSplitViewController , which refers to the three NSViewController and displays their views horizontally - with vertical dividers - (similar to the layout that you see in the application or pages in Yosemite +). My ultimate goal will be that the button on the "My" toolbar shows and hides the first split.
This is my understanding, and I would expect that for this I should create an action in the NSSplitViewController that more or less replaces the limitations of the automatic layout in how they work here: How to minimize and expand the view in a Mac application? .
And then somehow connect this action with the NSButton, which is on the toolbar ... which happens to be in the NSWindowController (remotely and isolated in the hierarchy) ...
I already looked at other questions about NSToolbar and storyboards and couldn't complete my task:
- YouTube Video: Cocoa Programming L17 is NSToolbar , which is closest to solving the problem, but its method does not work for storyboards, creating only your own xib file.
- In this question: How to use NSToolBar in Xcode 6 and storyboard? One person suggests making a link using the first reviewer, and expects that everything will connect to the launch (which looks a bit quirky, and not how the apple will implement it, I think ...). The second person suggested creating a view controller variable in NSWindowController and manipulating its properties from there ... but again, a bit dodgy.
- One last comment I saw on this question, which seems to be the best way to solve the problem (but still not as good as I assume it might be), was to add NSObjectController to the dock of each scene and when loading the scene set the values of the objects to another selenium controller. Is this really the best way to go next? If so, how can I achieve this?
Apple mentioned (once again) in WWDC15 that they created storyboards for osx and a split view controller that owns view controllers so that you can move your logic and work with a specific view controller, so I would expect to do everything from inside my controller with a split image as it is the goal that needs to be changed.
Does anyone know how to achieve this from the controller itself? I really could not find a way to associate my ToolBarItem with it.
swift xcode7 macos nstoolbar nssplitviewcontroller
gbdavid
source share