I've been trying to build on a Cocoa app that uses Swift and Storyboard in Xcode 6, but how can I use NSToolbar
there?
In Xcode 5 and xib, you can add NSToolbar
from within Object Library to any .xib files and then click on the added toolbar to expand it and drag and drop a connection from any items there to a AppDelegate.h
file. In this way you can create a IBAction
or IBOutlet
connection. I confirmed that this can also be done if you use Swift and non-storyboard in Xcode 6. However, it looks like this is not the case in Xcode 6 and Storyboard environment.
I first created a project that uses Storyboard in Xcode 6, but then, I wasn't able to add a NSToolbar
from within Object Library to a View Controller in Storyboard. So I added it to Window Controller's Window object in Storyboard. However, in this way I cannot create those connections from any items in the expanded toolbar to either AppDelegate.swift
or ViewController.swift
.
So my question is:
- Is it feasible to create a storyboard app that uses
NSToolbar
?
- If it is feasible, is the addition of
NSToolbar
to the Window Controller the proper way to use NSToolBar
in Storyboard?
- Finally, how can I create
@IBOutlet
and @IBAction
connections there?
UPDATE
I found that the accepted answer by @GeorgeVillasboas only works for @IBAction
. I am still looking for how to create an @IBOutlet
connection...
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…