Is there a way to define a NSDictionary * var or property so that only contravariant of a class are accepted for the key?
i.e. something that would look like this:
NSDictionary<__contravariant MYSubclass, id> *dictionary;
?
Is there a way to define a NSDictionary * var or property so that only contravariant of a class are accepted for the key?
i.e. something that would look like this:
NSDictionary<__contravariant MYSubclass, id> *dictionary;
?
Sorry for my ignorance. What do you mean by contravariant of a class
Apparently, there are __covariant and __contravariant attributes in Objective-C.
__contravariant would mean, AFAIK, that only instances of MySubClass or its super classes would be possible keys. Instances of a subclass of MySubclass would not be allowed.