我正在尝试将Typhoon集成到我的应用程序中,但只遇到了一个问题。
我有3个继承自TyphoonAssembly的类。其中一个依赖于另一个。
以下是具有依赖关系的程序集的代码
@interface SMObjectFactory : TyphoonAssembly
@property(nonatomic, strong, readonly) SMManagersAssembly *managersAssembly;
- (SMNote *)createEmptyNoteWithCurrentDate;
@end
// ===================================
@implementation SMObjectFactory {}
- (SMNote *)createEmptyNoteWithCurrentDate {
return [TyphoonDefinition withClass:[SMNote class] configuration:^(TyphoonDefinition *definition) {
[definition useInitializer:@selector(init)];
NSDate *dateAdded = [NSDate date];
[definition injectProperty:@selector(key) with:[NSString UUID1WithDate:dateAdded]];
[definition injectProperty:@selector(dateAdded) with:dateAdded];
[definition injectProperty:@selector(folderKey) with:self.managersAssembly.folderManager.defaultFolder];
}];
}
@end调用self.managersAssembly.folderManager.defaultFolder时出现问题。这里的self.managersAssembly是TyphoonCollaboratingAssemblyProxy的一个实例,因此,self.managersAssembly.highlightManager是TyphoonReferenceDefinition的实例,而不是应该由folderManager分别返回的实际程序集和对象。
在Info.plist中定义的程序集如下

我试着改变这些物品的顺序,但没有成功。
如果没有self.managersAssembly.folderManager.defaultFolder行,它会成功编译,例如,如果在app委托类(也是注入的)中,我调用(SMManagersAssembly *)self.assembly highlightManager.defaultHighlight,它就会工作得很好。
我做错了什么,正确的方法是什么?
台风2.2.1
发布于 2014-10-07 22:25:50
要做你想做的事情,请参考用户指南中的'Injecting Objects Produced by Other Components',其中概述了两种风格的基本相同的事情。请使用最适用的版本。
另请注意:
您可以创建一个或多个部件。在后一种情况下,通过声明属性,一个程序集中的组件可以引用另一个程序集中的组件。例如:
@interface PFApplicationAssembly : TyphoonAssembly
@property(nonatomic, strong, readonly) PFCoreComponents *coreComponents;
@property(nonatomic, strong, readonly) PFThemeAssembly *themeProvider;
@endTyphoon将使用满足上述条件的任何程序集组合来构建您的应用程序,例如{PFApplicationAssembly,TestCoreComponents,ColorfulThemes}
如果你想要覆盖一个定义(比如test vs production),你应该只覆盖一个程序集,否则组件可以像上面显示的那样相互引用。
https://stackoverflow.com/questions/26237746
复制相似问题