Daily iOS
UIKit

Separating dataSource and delegate

Why did Apple design UITableView with two protocols, dataSource and delegate, instead of just letting you hand it a data array?

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

dataSource is what to show and how many, delegate is how it looks and how it responds; the two change for different reasons. Because it's a protocol and not an array, the table view doesn't know the data type and lazily requests only the cells it needs.

Share a question