Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
Objective-C 类可以实现一个协议。反过来是真的吗——Objective-C 协议可以有类别吗?
不。
协议可以具有@required和@optional方法,从编译器的角度来看是相似的(编译器不会以通常定义的方式验证类别方法和延续类别方法)。
@required
@optional
协议还可以扩展其他协议。例如,您自己定义的几乎所有协议都应该扩展<NSObject>.
<NSObject>