Daily iOS
UIKit

Per-cell countdown with reuse

Each cell in a UITableView flash sale list shows a countdown like "Time left 00:12:34" that ticks down every second. Instead of one Timer per cell, how would you design it?

How would an interviewer hear this answer? You'll see whether they'd move on, dig in, or say no, and which sentences would trip you up. Your score doesn't change.
See the short answer

Keep one timer per screen (RunLoop .common mode) and update only the visible cells every second. Cells hold no state; they display the difference between the model's end time and now.

Share a question