-6

Hi I have a small doubt on UITABLEVIEW methods. For Tableview we have DATASORCE AND DELEGATE methods. Datasource and delegate both are protocols only right. Why we need two protocols ?instead of two protocols can we use one protocol where both delegate and datasorce methods are declared.

Datasource protocol having methods which help us for getting data and deciding the height of the cell.

Delegate protocol having methods which will concentrate on functionality of tableview.

Please let me clear this. Thanks in advance.

Naresh
  • 363
  • 1
  • 18
  • Please refer [TableView Guide](https://developer.apple.com/library/ios/documentation/UserExperience/Conceptual/TableView_iPhone/AboutTableViewsiPhone/AboutTableViewsiPhone.html#//apple_ref/doc/uid/TP40007451) – βhargavḯ Nov 27 '13 at 06:58
  • Please learn data source and delegates first, you can't merge two different functionalities in one. Both are serving their purpose. – Vinay Jain Nov 27 '13 at 06:58
  • If it is possible then why we use two class in our project .m and .h – Parvendra Singh Nov 27 '13 at 07:12

1 Answers1

0

Why we need two protocols?

The datasource and the delegate serve very different needs. By having them separate, you can have one object act as the datasource and another object act as the delegate.

sosborn
  • 14,676
  • 2
  • 42
  • 46