Is there any way to extend a class in Objective C only for those subclasses that conform to a protocol, like that in Swift:
extension SomeClass where self: SomeProtocol {
// some code
}
Is there any way to extend a class in Objective C only for those subclasses that conform to a protocol, like that in Swift:
extension SomeClass where self: SomeProtocol {
// some code
}
There is no Objective-C syntax for that. (Not sure if there’s even a Swift syntax like this; we have a generic where clause, but not on self
. And Objective-C doesn’t offer full generic implementation, only offering lightweight implementation.)