There seem to be dozens of threads for this for iOS and objective C, but the only one for macOS and swift is unanswered: Access an IBOutlet from another class in Swift
In an NSTabView I have an IBOutlet for an NSPopUpButton (popup1) in another tab (Tab3) [. When I press 'Save' it collects information from all tabs, including accessing the indexOfSelectedItem property of popup1.
My approach:
create an instance of Tab3, e.g.
let tab = Tab3()
access the outlet via
tab.popup1!.indexOfSelectedItem
Error during execution: Fatal error: Unexpectedly found nil while unwrapping an Optional value And yes, Tab3's ViewController did already load at the time of execution of this command.
I believe this is because an instance of the ViewController does not have access to the IBOutlets. So, the question remains, how can I access the properties of the IBOutlet?