是否可以有一个程序集来定义基本配置并将其子类化以具有其他配置?
我正在尝试这样的事情:
@interface RootAssembly : TyphoonAssembly
- (id)abstractObject;
- (id)object;
@end
@implementation RootAssembly
- (id)abstractObject {
return [TyphoonDefinition withClass:[NSObject class]];
}
- (id)object {
return [TyphoonDefinition withParent:[self abstractObject] class:[NSObject class]];
}
@end
@interface ChildAssembly : RootAssembly @end
@implementation ChildAssembly
- (id)object {
return [TyphoonDefinition withParent:[super abstractObject] class:[NSObject class]];
}
@end
如果只使用一个组件,一切正常。如果还实例化并激活了第二个,则返回的方法object
尚未混合并尝试构建定义,从而导致异常:
2015-05-27 18:44:37.542 Typho[17693:8488013] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: 'Only TyphoonDefinition object can be set as parent. But in method '(null)' object of class NSObject set as parent'
在这里查看更多信息:https ://gist.github.com/oettam/01ac812c040ed28d913c
这真的是要走的路吗?