私は何か基本的なものが欠けていると思います...
NSCoding
でクラスと子を実装しましたが、子クラスのNSCoding
を呼び出すとエラーが発生します。initWithCoder
InvalidArgument
@interface Parent: NSObject<NSCoding>;
@implementation Parent
-(id)initWithCoder:(NSCoder *)decoder {
self = [[Parent alloc] init];
return self;
}
@end
@interface Child: Parent<NSCoding>;
@implementation Child
-(id)initWithCoder:(NSCoder *)decoder {
self = [super initWithCoder:decoder]; //self is Parent type here
// self = [[Child alloc] init]; if i do that, no error but no init for the parent'attribute
if(self){
self.childAttribute = [decoder decodeObjectForKey:@"KeyAttribute"]; // invalide argument ==> setChildAttribute doesn't exist.
}
return self;
}
基本的なことを忘れたに違いないのですが、何がわからないのですか... 誰かアイデアがありますか?
ありがとう。