For instance, in the app I'm working on, a user can create a post, and other users are then able to reply to that post. people can then comment the reply. My question is: Would it be better for the memory to split a post with multiple replies and comments into many cells, or keep them in one cell?
Asked
Active
Viewed 63 times
-6
-
next time when you post question don't put "what is the best practice?" – Nazmul Hasan Apr 16 '17 at 15:49
-
@NazmulHasan It's actually not exactly the best practice I'm looking for. It's more, what requires least CPU or memory. – Kasper Hansen Apr 16 '17 at 15:55
-
whatever check this link https://meta.stackoverflow.com/questions/265928/is-a-best-practice-question-off-topic – Nazmul Hasan Apr 16 '17 at 15:59
1 Answers
0
With reusable cells or views, UITableview never makes more instances of the visual components than necessary. Your underlying data source may have thousands of rows but there will never be more actual cells than will fit on the screen (plus a few more for scrolling).
One of the most common issues people come across with this is the effect of cell recycling as they often forget to initialize all components of a cell (that may or may not be "recycled").

Alain T.
- 40,517
- 4
- 31
- 51
-
So it doesn't matter if I split a post with replies and comments into 5 cells or unify them to one cell? – Kasper Hansen Apr 16 '17 at 15:57
-
1It's a bit more memory efficient to split it in multiple cell rather than trying to create a huge composite cell (if there can be a large number of replies and comments). Visual design considerations will be a bigger factor in your design decision. UITableView is pretty efficient and you can rely on it to do the right thing. – Alain T. Apr 16 '17 at 16:12
-