I like to build an app in Swift 3 with Xcode 8 and it should enable the Apple tab bar. It is not document-based. I learned here, that the tabs can be enabled if I override t
In case above "+" will add new tab always after first window, if you close first window then it will be recreated under current window.
there is way to get it work
override func newWindowForTab(_ sender: Any?) {
let wc: NSWindowController = self.storyboard?.instantiateInitialController() as! NSWindowController
wc.window?.windowController = self
NSApplication.shared.mainWindow!.addTabbedWindow(wc.window!, ordered: .above)
wc.window?.orderFront(self)
}
trick in NSApplication.shared.mainWindow! you always add tab to current active window.
and if we need create window at the end we should use this trick
let tabbedWindows = NSApplication.shared.mainWindow!.tabbedWindows!
let lastTabIdx = tabbedWindows.count - 1
tabbedWindows[lastTabIdx].addTabbedWindow(wc.window!, ordered: .above)