txtOutput should be connected as @IBOutlet and not as a @IBAction
with @IBAction you only trigger some actions but you don’t get a reference to the object
with @IBOutlet you get a reference to the object and can access the properties like .text of this object
Just be carefully when you drag the connections from IB to the code
for iOS your code should be look like (since you use NSViewController it should be the Cocoa object for it)
@IBOutlet var txtOutput: UILabel!
// or
@IBOutlet weak var txtOutput: UILabel!
but dont just change the code. double check if this connection is also assigned at the Label in InterfaceBuilder
Update
now you can set the text with:
txtOutput.stringValue = "Hello"
5
solved swift 3 textlabel text is true [closed]