- Getting the Tools
- Types of Apple Watch Applications
- Populating the User Interface
- Testing the Watch Application
- Summary
Populating the User Interface
Let’s add a Label view to the Interface Controller (see Figure 10).
Figure 10 Adding a Label view to the Interface Controller.
Click the Show the Assistant Editor button; then Control-click and drag the Label view onto the code editor, as shown in Figure 11. Name the outlet label (see Figure 12).
Figure 11 Control-click the Label view and drag it over the code editor.
Figure 12 Naming the outlet.
This process creates an outlet in the InterfaceController.swift file:
import WatchKit import Foundation class InterfaceController: WKInterfaceController { @IBOutlet weak var label: WKInterfaceLabel! override init(context: AnyObject?) { // Initialize variables here. super.init(context: context) // Configure interface objects here. NSLog("%@ init", self) }
Add the following statement in bold to the InterfaceController.swift file:
override init(context: AnyObject?) { // Initialize variables here. super.init(context: context) // Configure interface objects here. NSLog("%@ init", self) self.label.setText("Hello, Apple Watch!") }