Helldog Helldog - 1 year ago 153
iOS Question

dequeueReusableCell() vs UITableViewCell()

I'm implementing search with autofill. I have

. When user changes text in text field I'm loading new data from server and displaying it in table view.

Number of results is fixed(5 or less). Height of table is connected to number of results, so it will never scroll. When new results arrive i simply call
for table.

So the question is should i use
or create new cells with
, as they will never reuse? Will
clear all memory for cells if they were created without dequeuing?

Answer Source

The main purpose of dequeueReusableCell() is to reuse the UITableViewCell that is created already in memory, instead of recreating it, therefore, it runs faster on the CPU than having to recreate a UITableViewCell each time you need one. It has nothing to do with the content you give it.

So it's always preferable to use dequeueReusableCell() as it makes the app run smoother. Even if the difference is negligible.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download