今天在Xcode 4.6中进入今天,它让我感到惊讶。我正在使用自动合成属性(但手动合成没有区别)。
@interface TestA : NSObject
@property (strong) id foo;
@end
#import "TestA.h"
@interface TestB : TestA
- (id)initWithFoo:(id)foo;
@end
@implementation TestB
- (id)initWithFoo:(id)foo
{
self = [super init];
if (self)
{
_foo = foo; // Xcode says _foo is not defined.
//self.foo = foo; // This does work though.
}
return self;
}
@end
我可以在_foo
的实施中访问TestA
,但不在TestB
中。我可以通过在id _userInfo
中将TestA.h
作为ivar声明来解决这个问题,但我认为不必这样做。这里发生了什么?