Modifying Tables
Whereas setting up a table’s contents in WatchKit is markedly different from using UITableView on iOS, modifying the content once you’ve done that initial setup is pretty similar—you just need to tell the table where to add the rows. To support what you’re going to do in the next chapter, let’s include support for adding a new run to the table once you’ve set everything up.
You’ll use the interface controller’s awakeWithContext method to receive the data. When you get a Run passed in as the context, you’ll use the table’s insertRowsAtIndexes(_:withRowType:) method to add the row. You’ll then use its rowControllerAtIndex just like when you set up the table, but this time just for the newly inserted row. Your method will look ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access