WatchKit-Distinguish among tables in table(table, didSelectRowAtIndex)

281 views Asked by At

I have 2 tables in my WKInterfaceController. Clicking on their rows will push to different WKInterfaceController. I need to use override func table(table: WKInterfaceTable, didSelectRowAtIndex rowIndex: Int) because I need to pass a context object.

How do I tell which WKInterfaceTable row is clicked?

Something like this:

override func table(table: WKInterfaceTable, didSelectRowAtIndex rowIndex: Int) {
    // If condition A is satisfied
    {
        presentControllerWithName("WKControllerA", context: self)
    }
    else
    {
        presentControllerWithName("WKControllerB", context: self)
    }
}
1

There are 1 answers

0
rmp On BEST ANSWER

just check the table and rowIndex like this:

override func table(table: WKInterfaceTable, didSelectRowAtIndex rowIndex: Int){

    if table==myTable1 && rowIndex==myIndex {

            //do something

    } else if table==myTable2  && rowIndex==myIndex2  {

            //do something else

    }
}