Alex Rivera | Logout

Does a subclass inherit the protocols of its parent class in Objective-C?

Asked 2011-05-19T12:26:11.663
22

Suppose I have a parent class that implements a protocol:

@interface GameViewController : UIViewController<GamePrizeDelegate> {
  ...
}

And then I make subclasses of it:

@interface TennisViewController : GameViewController {
  ...
}

@interface SoccerViewController : GameViewController {
  ...
}

Do I have to include the GamePrizeDelegate also in the subclasses? Are the protocols inherited as well?

Thanks!

Edit
Report

1 Answer

29

Referring to Apple's documentation: Your subclass does inherit the adoption of the protocol, so you don't have to adopt it again.

Conforming to a Protocol

A class is said to conform to a formal protocol if it adopts the protocol or inherits from another class that adopts it. An instance of a class is said to conform to the same set of protocols its class conforms to.

answered 2011-05-19T12:30:39.683

Your Answer