views:

57

answers:

1

I saw this in some header file in the framework directory:

@interface NSCharacterSet : NSObject <NSCopying, NSMutableCopying, NSCoding>

@end

@interface NSMutableCharacterSet : NSCharacterSet <NSCopying, NSMutableCopying>

@end

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?

+7  A: 

Yes. Subclasses will adopt the same protocols as well.

The reason Apple typing that again is because NSMutableCharacterSet has overridden -copyWithZone: and -mutableCopyWithZone:.

KennyTM