Like iOS where you use @IBOutlet
and @IBAction
, here you could use them too.
Let's say we have a button which when clicked changes the label's text to something else.
To get started:
Add a WKInterfaceLabel
and a WKInterfaceLabel
to the InterfaceController
.
Ctrl-Drag from the WKInterfaceLabel
to InterfaceController.swift
and enter the details as shown in the following picture to add an outlet property:
WKInterfaceButton
to InterfaceController.swift
and enter the details as shown in the following picture to add an action method:outputLabel.setText("Button Tapped!")
[[self outputLabel] setText:@"Button Tapped!"]