gpt4 book ai didi

objective-c - 子类是否继承了 Objective-C 中其父类的协议(protocol)?

转载 作者:太空狗 更新时间:2023-10-30 03:12:21 25 4
gpt4 key购买 nike

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

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

然后我创建它的子类:

@interface TennisViewController : GameViewController {
...
}

@interface SoccerViewController : GameViewController {
...
}

我是否还必须在子类中包含 GamePrizeDelegate?协议(protocol)是否也被继承?

谢谢!

最佳答案

引用Apple's documentation : 你的子类确实继承了协议(protocol)的采用,所以你不必再次采用它。

Conforming to a Protocol

A class is said to conform to a formalprotocol if it adopts the protocol orinherits from another class thatadopts it. An instance of a class issaid to conform to the same set ofprotocols its class conforms to.

关于objective-c - 子类是否继承了 Objective-C 中其父类的协议(protocol)?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6058591/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com