Group Group Group Group Group Group Group Group Group

Confusion about the cells in Checklist app



I just started working on Checklist app, I have a query if any one can kindly guide -

  1. I add a cell to the table row , call it Checklistitem

  2. There is a label also with tag 1000

  3. When the number of rows is increased to 1000 and we use % operator to fill all rows , is the same cell being duplicated on all rows ?

4)Also is the same label being duplicated, if so how can we avoid this duplication of cells and labels and what if I need a new cell or a label on next row ?

Please guide



Hi Amit, essentially the tableview cells are being reused. Using the method dequeueReusableCell(withIdentifier:) is used to make sure the tableview performs well. Because there is a list of objects waiting to be used, it’s best to reuse the cell so each object can appear when it’s their turn (when the user scrolls down). With the label, because it is inside the cell, it will display whatever object comes next from the queue.

Furthermore, when you first setup your tableview and cell there might not be any data to be displayed so you will most likely see the same cell over and over until you tell the tableview to display your data (Ex: an array with names, or an API with movie titles, etc). Since you are working on the Checklist app, once you have completed the tutorial you should see different items on that checklist while under the hood, the cell is being reused. Hope this helps and happy coding!



@gdelarosa - thanks, so it means I only need just one cell and use the dequereusable method ? and there are no situations where I might need multiple cells and use dequereusable on them ?


For most use cases you can satisfy most requirements with one cell on one tableview or collectionview.