単純なスーパー/サブ クラス スキームの実装で問題が発生しています。スーパークラスで NSMutableDictionary を宣言し、サブクラスでアクセスしようとしていますが、null しか返されません。どんな助けでも大歓迎です。
@interface RootModel : NSObject <Updatable, TouchDelegate>
@property (nonatomic) NSMutableDictionary *gameValues;
@end
@interface SubclassModel : RootModel
@end
@implementation RootModel
- (id)initWithController:(id)controller {
if ((self = [super init])) {
_controller = controller;
_gameValues = [NSMutableDictionary dictionaryWithObjectsAndKeys:
[NSNumber numberWithFloat:300.0f], KEY_JUMP_VELOCITY,
[NSNumber numberWithFloat:49.47f], KEY_GRAVITY,
[NSNumber numberWithFloat:0.25f], KEY_JUMP_TIME_LIMIT,
nil];
NSLog(@"%@", _gameValues);
}
return self;
}
@implementation SubclassModel
- (id)init{
if ((self = [super init])) {
// This NSLog prints "(null)" if using super.gameValues or self.gameValues, why?
NSLog(@"subclass: %@", super.gameValues);
}
return self;
}
@end
私は何を間違っていますか?