Answer the question
In order to leave comments, you need to log in
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
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 questionAsk a Question
731 491 924 answers to any question