今天讲Objective-C的protocol的继承。
Protocols Inherit from Other Protocols
In the same way that an Objective-C class can inherit from a superclass, you can also specify that one protocol conforms to another.
As an example, it’s best practice to define your protocols to conform to the NSObject protocol (some of the NSObject behavior is split from its class interface into a separate protocol; the NSObject class adopts the NSObject protocol).
By indicating that your own protocol conforms to the NSObject protocol, you’re indicating that any object that adopts the custom protocol will also provide implementations for each of the NSObject protocol methods. Because you’re presumably using some subclass
of NSObject, you don’t need to worry about providing your own implementations for these NSObject methods. The protocol adoption is useful, however, for situations like that described above.
To specify that one protocol conforms to another, you provide the name of the other protocol in angle brackets, like this:
@protocol MyProtocol <NSObject>
...
@end
In this example, any object that adopts MyProtocol also effectively adopts all the methods declared in the NSObject protocol.