-2

Sorry for this simple question, but I don't understand how to get the references to my components in the GUI that I built in Main.storyboard. This is how it looks like right now:

enter image description here

func applicationDidFinishLaunching(_ aNotification: Notification) {
    let myWindowController = NSStoryboard(name: NSStoryboard.Name(rawValue: "Main"), bundle: nil).instantiateController(withIdentifier: NSStoryboard.SceneIdentifier(rawValue: "abcd")) as! MyMainWindow
    myWindowController.showWindow(self)

The View Controller on the top left is my "MyMainWindow" (NSWindowController) with the ID "abcd". Now, I would like to access the components like this checkbox in Tab1 in my code:

enter image description here

In Android i.e. you do something like findViewById(R.id.idOfTheComponent), but I've seen that in Xcode you can Ctrl-Drag the Component into a ViewController. I didn't work though, when I tried to drag the checkbox into my ViewController.swift class. Can someone help?

Cemal K
  • 96
  • 8
  • 2
    Please go through this once https://developer.apple.com/library/archive/referencelibrary/GettingStarted/DevelopiOSAppsSwift/ConnectTheUIToCode.html – Kamran Jun 05 '18 at 09:20
  • Is `ViewController` the class of the view controller of tab 1? You can't connect a checkbox to the view controller of a different scene. – Willeke Jun 05 '18 at 09:40

1 Answers1

1

The correct way to search for this problem is how to create IBOutlets or please refer to the Apple documentation on this

sanjaykmwt
  • 586
  • 3
  • 19