Search code examples
iosxcodeswiftuitableviewwatchkit

Call to Setup Table in WatchKit


I have a WatchKit app and can't figure out the best place to call my function that sets up the table in my InterfaceController.

InterfaceController:

   var receivedData = Array<Dictionary<String, String>>()

    var eventsListSO = Array<Event>()

    @IBOutlet var rowTable: WKInterfaceTable!

    func doTable() {

        eventsListSO = Event.eventsListFromValues(receivedData)
        rowTable.setNumberOfRows(eventsListSO.count, withRowType: "rows")

        for var i = 0; i < self.rowTable.numberOfRows; i++ {
            let row = rowTable.rowControllerAtIndex(i) as? TableRowController
            for eventm in eventsListSO {
                row!.mLabel.setText(eventm.eventMatch)
                NSLog("SetupTableM: %@", eventm.eventMatch)
            }
        }

    }

If my doTable code looks correct and where to call it in InterfaceController?


Solution

  • Per @KosukeOgawa, willActivate