Delegates in OSX

Hi, i’m trying to get delegates working for an OSX app with Swift.

import Cocoa

class loginViewController: NSViewController {
    weak var delegate: recordViewControllerDelegate?

    override func viewDidLoad() {
      super.viewDidLoad()
      // Do view setup here.
      delegate?.trySomething()
      self.delegate?.trySomething()
      self.delegate?.testPrint("hello, is it me your looking for")
    }
}

protocol recordViewControllerDelegate: class {
  func testPrint(val: String)
  func trySomething()
}

class recordViewController: NSViewController, recordViewControllerDelegate {

  func testPrint(val: String) {
    print(val)
  }

  func trySomething() {
    print("aaa")
  }
}

Everything looks right but testPrint & trySomething never get called, added breakpoints but nothing happens.

Any ideas what i’m missing?

Driving me nuts

‘loginViewController’ has a property ‘delegate’ which must conform to ‘recordViewControllerDelegate’, but in the code you’ve written, ‘delegate’ has a value of nil.

Where’s the code where you set ‘delegate’ to another value, e.g. to an instance of ‘recordViewController’?