想象一下我有两个协议:
@protocol A
@end
和
@protocol B <A> // Protocol B conforms to protocol A.
@end
还有两个变量:
id<A> myVar = nil;
和
id<B> otherVar = //correctly initialized to some class that conforms to <B>;
那么,为什么我不能将 'otherVar' 分配给 'myVar' 呢?
myVar = otherVar; //Warning, sending id<B> to parameter of incompatible type id<A>
谢谢!