I am starting to learn swift code, with this code after entering your name and pressing the button will appear greeting information. I want to not need to press the button, when I open the application, can it run this code by itself? with the words "Hello World!"
var name = nameField.stringValue
if name.isEmpty {
name = "World"
}
let greeting = "Hello \(name)!"
helloLabel.stringValue = greeting
Put the code into viewDidLoad
.
override func viewDidLoad() {
super.viewDidLoad()
...
}