I'm trying to build a simple WatchKit app with a Table. Each row has a Label. Here's my TableRowController class:
import WatchKit
class TaskTableRowController: NSObject {
@IBOutlet var taskName: WKInterfaceLabel!
}
In my InterfaceController, I add a row to my Table and try to set the Label's text. However, taskList.rowController(at: 0) does not find a row, so the Label is unmodified.
import WatchKit
import Foundation
class InterfaceController: WKInterfaceController {
@IBOutlet var taskList: WKInterfaceTable!
override func awake(withContext context: Any?) {
super.awake(withContext: context)
// Configure interface objects here.
taskList.setNumberOfRows(1, withRowType: "TaskRow")
if let x = taskList.rowController(at: 0) as? TaskTableRowController
{
x.taskName.setText("Hello World")
}
}
override func willActivate() {
// This method is called when watch view controller is about to be visible to user
super.willActivate()
}
override func didDeactivate() {
// This method is called when watch view controller is no longer visible
super.didDeactivate()
}
}