1

I'm trying to implement a separate class for UICollectionViewDelegate and UICollectionViewDataSource. However, I always seem to need access to the data model in order to calculate certain Delegate methods such as size of a cell.

I've never seen these two protocols implemented in separate classes, so why does Apple make them distinct protocols?

quark
  • 1,725
  • 1
  • 14
  • 23
  • 2
    Nice question ! For me, datasource is for providing the data and delegate for responding to the events and customizing the style. You should looks at http://stackoverflow.com/questions/5714528/difference-between-uitableviewdelegate-and-uitableviewdatasource – Michaël Azevedo Dec 15 '15 at 21:11

1 Answers1

2

I have implemented them in different classes when I have wanted to display the same data differently in two or more separate view controllers. This scenario is rather unusual on iOS but happens reasonably often if you develop for OS X.

Lev Landau
  • 788
  • 3
  • 16