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. ...
Get Developing for Apple Watch, 2nd Edition now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.