为什么将一个扩展协议的id分配给同样扩展相同协议的对象会产生警告,有时会用'Object * __ strong'初始化一个不兼容类型'id'的表达式?我不是要求抑制警告的方法。
@protocol PA <NSObject>
@end
@interface A1 : NSObject <PA>
@end
@interface A2 : NSManagedObject <PA> // Same for NSString in Xcode 8
@end
@protocol PB
@end
@interface B1 : NSObject <PB>
@end
@interface B2 : NSManagedObject <PB>
@end
A1 *a1 = (id<PA>)nil; // no warnings
A2 *a2 = (id<PA>)nil; // warning in Xcode 8. initializing with 'A2 *__strong' an expression of incompatible type 'id<PA>'
B1 *b1 = (id<PB>)nil; // warning in Xcode 8 and 7
B2 *b2 = (id<PB>)nil; // warning in Xcode 8 and 7