Is it possible to implement protocol chaining?
For example, I’m defining a new protocol (ProtocolA), and I’d like to make sure that it can only be applied to objects that conform to ProtocolB. So something like…
@protocol ProtocolA <NSObject<ProtocolB>>
@end
Question
Does objective C allow this type of behaviour? If not is there a design pattern I should be aware of to achieve a similar effect?
Instead of using inscribed protocols (which is improper format), simply separate each individual protocol with a comma like so:
It’s perfectly legal. In fact, several hundred UIKit protocols are declared along these lines.