Zalando Jul 7, 2016

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

Critical Insight

Data binding location doesn't impact UITableView performance because both methods execute before layout in the same cycle.

The article hints at upcoming changes in iOS 10 that will alter the call order between these methods entirely.

About This Article

Problem

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.

Solution

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.

Impact

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.