Proper Use of CellForRowAtIndexPath and WillDisplayCell
Article Summary
Zalando's iOS team challenges a widely-cited performance myth about UITableView that's been misleading developers for years.
Engineer Yunus Eren Guzel investigates whether willDisplayCell actually improves scrolling performance over cellForRowAtIndexPath, a claim popularized in Alexander Orlov's influential article on UITableView optimization. Using layout cycle analysis and logging, he tests whether the timing difference matters.
Key Takeaways
- Both cellForRowAtIndexPath and willDisplayCell execute in the same layout cycle
- layoutSubviews runs after both methods, so neither displays cells faster
- Apple's documentation shows willDisplayCell is for overriding state properties only
- Performance bottlenecks affect scrolling regardless of which method you use
Data binding location doesn't impact UITableView performance because both methods execute before layout in the same cycle.
About This Article
Developer Yunus Eren Guzel found that Alexander Orlov's widely-cited article made claims about willDisplayCell performance benefits without solid evidence. This created confusion in the iOS development community.
Guzel added logging to cellForRowAtIndexPath, willDisplayCell, and layoutSubviews to track when each method runs. The logs showed both methods execute one after the other in the same layout cycle, before rendering happens.
The analysis proved the execution order. cellForRowAtIndexPath and willDisplayCell finish before layoutSubviews rendering starts. This disproved the performance claim that had misled developers for years.