简体   繁体   中英

Typhoon module dependencies resolved to TyphoonCollaboratingAssemblyProxy

I'm trying to integrate Typhoon Framework into my app and stuck with one problem.

I have 3 classes that inherited from TyphoonAssembly . One of them depends on another one.

Here is a code of the assembly that has dependency

@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

The problem occurs when calling self.managersAssembly.folderManager.defaultFolder . Here is self.managersAssembly is an instance of TyphoonCollaboratingAssemblyProxy , hence, self.managersAssembly.highlightManager is instance of TyphoonReferenceDefinition instead of actual assembly and object that should be returned by folderManager respectively.

Assemblies defined in Info.plist as following

在Info.plist中定义的程序集如下

I tried to change ordering of these items, no luck.

Without the self.managersAssembly.folderManager.defaultFolder line it compiles successfully and if, for example, in app delegate class (which is also injected) I call [(SMManagersAssembly *)self.assembly highlightManager].defaultHighlight it works perfectly well.

What I'm doing wrong and what is the propper way of doing it?

Typhoon 2.2.1

To do what you would like please refer to 'Injecting Objects Produced by Other Components' in the User Guide, which outlines two styles of doing essentially the same thing. Use the one that is most applicable.

Also note that:

You create one or more assemblies. In the latter case components in one assembly can refer to components in another, by declaring a property. For example:

@interface PFApplicationAssembly : TyphoonAssembly

@property(nonatomic, strong, readonly) PFCoreComponents *coreComponents;
@property(nonatomic, strong, readonly) PFThemeAssembly *themeProvider;

@end

Typhoon will build your application with any combination of assemblies that fulfill the above, eg {PFApplicationAssembly, TestCoreComponents, ColorfulThemes}

You should only override an assembly if you wish to override a definition (eg test vs production), otherwise components can just refer to each other as shown above.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM