我试图手动实例化Initial viewControllers和卡住下一件事情。

这正在工作:

-(TyphoonStoryboard *)storyboard {
    return [TyphoonDefinition withClass:[TyphoonStoryboard class] configuration:^(TyphoonDefinition* definition) {
        [definition useInitializer:@selector(storyboardWithName:factory:bundle:) parameters:^(TyphoonMethod *initializer) {
            [initializer injectParameterWith:@"Diary"];
            [initializer injectParameterWith:self];
            [initializer injectParameterWith:[NSBundle mainBundle]];
        }];

        definition.scope = TyphoonScopeSingleton;
}];
}

-(LADiaryMainViewController *)mainViewController {
    return [TyphoonDefinition withFactory:[self storyboard] selector:@selector(instantiateInitialViewController)];
}

并且这不起作用:
-(TyphoonStoryboard *)storyboardWithName:(NSString *)name {
    return [TyphoonDefinition withClass:[TyphoonStoryboard class] configuration:^(TyphoonDefinition* definition) {
        [definition useInitializer:@selector(storyboardWithName:factory:bundle:) parameters:^(TyphoonMethod *initializer) {
            [initializer injectParameterWith:name];
            [initializer injectParameterWith:self];
            [initializer injectParameterWith:[NSBundle mainBundle]];
        }];
    }];
}

-(LADiaryMainViewController *)mainViewController {
    return [TyphoonDefinition withFactory:[self storyboardWithName:@"Diary"] selector:@selector(instantiateInitialViewController)];
}

第二种方法是崩溃:[__NSArrayM insertObject:atIndex:]: object cannot be nil

最佳答案

抱歉,Typhoon不支持带有运行时参数的factory definition。但是..我们已经为您添加了该功能!

检查Typhoon 3.1.9版本,您的代码现在应该可以正常工作。

09-07 09:57