在超类中MyClass:
@interface MyClass : NSObject
@property (nonatomic, strong, readonly) NSString *pString;
@end
@implementation MyClass
@synthesize pString = _pString;
@end
Run Code Online (Sandbox Code Playgroud)
在子类中 MySubclass
@interface MySubclass : MyClass
@end
@implementation MySubclass
- (id)init {
if (self = [super init]) {
_pString = @"Some string";
}
return self;
}
Run Code Online (Sandbox Code Playgroud)
问题是编译器不认为它_pString是成员MySubclass,但我在访问它时没有问题MyClass.
我错过了什么?