Home / tableview cell reuse interview question

UIKit

Table view cell reuse interview question

Cell reuse is a favorite UIKit question because the optimization that makes lists fast also causes a classic family of bugs.

How reuse works

To scroll thousands of rows smoothly, UIKit keeps a small pool of cells and recycles them: dequeueReusableCell hands back an off-screen cell instead of allocating a new one, and you reconfigure it for the current index path. This keeps memory and allocation bounded regardless of data size.

The bugs and the fixes

Because a cell carries leftover state, you get wrong images, stale text, or flicker if you do not fully reset it. Explain resetting mutable state in prepareForReuse, always configuring every visual property in cellForRowAt, and guarding against a slow async image load completing after the cell has been reused by checking the index path or using a cancellation token.

Go deeper than a summary

Share Your Screen works topics like this through in full: 75 solved Swift problems with tests, 9 real case studies, and 7 annotated mock interviews, so you rehearse the live round instead of just reading about it.

Get the book

Frequently asked

Why does my table view show the wrong image in a cell?

Because a reused cell kept the previous row's image, or an async load finished after reuse. Reset state and verify the target index path before applying the result.

What is prepareForReuse for?

It runs before a recycled cell is reused so you can clear leftover state like images, text, and selection that would otherwise leak into the next row.