Conforming to Protocols


#1

I’m a bit confused that I don’t write <UITableViewDelegate, UITableViewDataSource> in ItemsViewController.h. Is this because ItemsViewController inherits conforming to these protocols by being a subclass of UITableViewController?

Thanks!


#2

this is the Class Reference in the documentation:

UITableViewController Class Reference

Inherits from
UIViewController : UIResponder : NSObject
Conforms to
UITableViewDelegate
UITableViewDataSource
NSCoding (UIViewController)
UIAppearanceContainer (UIViewController)
NSObject (NSObject)

According to this http://stackoverflow.com/questions/6058591/does-a-subclass-inherit-the-protocols-of-its-parent-class-in-objective-c post in Stackoverflow, the protocols are inherited to the subclasses. Since you are writing a UITableView Subclass, the protocol is automatically adopted.


#3

If you check the header file for UITableViewController you’ll see that it declares self as the datasource and delegate. Therefor, you don’t need to add them to the @interface.