I want to have tab menu in my Mac desktop application, each tab will show progresbarr (loading content from internet) and then loaded data. I want to use the same LoadingViewController in each page and only pass what data should be downloaded (according to tab user selected). How I can pass information from NSTabViewController to child ViewController? This is how my storyboard looks:
In the storyboard "Document outline" pane (the collapsable one on the left that lists views, objects, etc), under the tab view controller there will be two objects labeled "Tab View Item". give each one of them an identifier. (in the below example, they are "entriesTabItem" and "contactsTabItem".
Then, subclass TabViewController, and in that subclass, add something like the following in "viewDidLoad":
override func viewDidLoad() {
super.viewDidLoad()
var entryIndex = self.tabView.indexOfTabViewItemWithIdentifier("entriesTabItem")
var entriesTVItem:NSTabViewItem = self.tabViewItems[entryIndex] as NSTabViewItem
var entriesVC:EntryViewController? = entriesTVItem.viewController as EntryViewController?
if (entriesVC != nil){
entriesVC!.topTabView = self.tabView
entriesVC!.topTabVC = self
}
var contactIndex = self.tabView.indexOfTabViewItemWithIdentifier("contactsTabItem")
var contactTVItem:NSTabViewItem = self.tabViewItems[contactIndex] as NSTabViewItem
var contactVC:ContactsViewController? = contactTVItem.viewController as ContactsViewController?
if(contactVC != nil) {
contactVC!.topTabView = self.tabView
contactVC!.topTabVC = self
}
}
In the code above, the view controllers could be of the same class instead of different as they are here, and you can pass whatever variables you wish.
I had to do this last week and it drove me crazy!