swiftwatchkitwatchoswkinterfacetable

Does setting setNumberRows de-allocate the unneeded rows?


I'm using a WKInterfaceTable on WatchOS.

If for example the table already has 5 rows,

and I

.setNumberOfRows(2, withRowType: "rows") so that it now only has 2 rows,

does that mean that the 3 rows that are no longer visible are deallocated

(or do I have to run apptTable.removeRows to de-allocate)?

Thanks


Solution

  • After you call .setNumberOfRows, the WKInterfaceTable will be updated, so yes, the extra 3 rows in your example will be removed. There's no need to manually call removeRows.

    This is explicitly stated in the documentation as well:

    Use this method when you want to populate a table with rows that are all of the same type. This method removes any existing rows from the table and configures a new set of rows based on the information in the numberOfRows and rowType parameters.