NSObjectProtocol
is more general than NSObject
and isEqual
and hash
are defined in NSObjectProtocol
. Logically, we should inherit NSObjectProtocol
from Equatable
and Hashable
.
Why not? Why instead extend NSObject
to conform to Equatable
and Hashable
?
The current design causes problems like this:
if obj.delegate == self {
Binary operator '==' cannot be applied to operands of type 'XXXDelegate' and 'XXXDelegate'
because delegates are NSObjectProtocol
not NSObject
.
The only reason I can think of is if we use the alternative design NSObjectProtocol
will become an protocol with Self or associated type requirement. But will it cause any negative effects? What are they?