3

我正在尝试手动实例化初始视图控制器并坚持下一件事。

这是有效的:

-(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

4

1 回答 1

1

糟糕.. 抱歉,factory definitionTyphoon 不支持运行时参数。但是..我们已经为您添加了该功能!

检查 Typhoon3.1.9版本,您的代码现在应该可以正常工作了。

于 2015-06-11T13:27:05.010 回答