问题描述
我在框架目录的某些头文件中看到了这一点:
I saw this in some header file in the framework directory:
@interface NSCharacterSet : NSObject <NSCopying, NSMutableCopying, NSCoding>
@end
@interface NSMutableCharacterSet : NSCharacterSet <NSCopying, NSMutableCopying>
@end
我认为协议是可继承的。那,则无需在 NSMutableCharacterSet:NSCharacterSet
之后再次键入< NSCopying,NSMutableCopying>
。和NSMutableCharacterSet还符合NSCoding协议,对吗?
I thought protocols were inheritable.If I am right about that,There is no need to type <NSCopying, NSMutableCopying>
again after "NSMutableCharacterSet : NSCharacterSet
".And NSMutableCharacterSet also conforms to NSCoding protocol, right?
然后为什么苹果要再次键入?我犯错了吗?
Than why is Apple typing that again?Am I making mistake?
推荐答案
是的。子类也将采用相同的协议。
Yes. Subclasses will adopt the same protocols as well.
Apple再次键入该文本的原因是NSMutableCharacterSet已覆盖 -copyWithZone:
和 -mutableCopyWithZone:
。
The reason Apple typing that again is because NSMutableCharacterSet has overridden -copyWithZone:
and -mutableCopyWithZone:
.
这篇关于协议可以在Objective-C中继承吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!