子类是否在Objective-C中继承其父类的协议? [英] Does a subclass inherit the protocols of its parent class in Objective-C?

查看:130
本文介绍了子类是否在Objective-C中继承其父类的协议?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

假设我有一个实现协议的父类:

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 {
  ...
}

我有吗在子类中还包括 GamePrizeDelegate ?协议是否也继承了?

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

谢谢!

推荐答案

参考 Apple的文档:您的子类继承了协议的采用,所以你不必再采用它。

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


符合协议

如果一个类采用协议,则认为该类符合正式的
协议,或者
继承自另一个类的
采用它
即可。一个类的实例是
表示符合其类符合的同一组
协议。

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.

这篇关于子类是否在Objective-C中继承其父类的协议?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆