W
W
WbdT2016-07-21 22:31:55
Swift
WbdT, 2016-07-21 22:31:55

How to correctly set a value from another class?

class ViewController: NSViewController {
  @IBOutlet weak var foldersLbl: NSTextField!

func setVal() {
foldersLbl.stringValue = "some"
}
}
//srcVC.swift:
class srcVC: NSImageView {
let vc = ViewController()
//vc.foldersLbl.stringValue = "some"<- crash
//vc.setVal() <- crash
}

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Anton Zhilin, 2016-07-22
@Anton3

Before the window is displayed, the fields of your `NSViewController` are disabled.
What to do -- make changes from some callback, for example `viewDidLoad`.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question