我正在尝试手动实例化初始视图控制器并坚持下一件事。
这是有效的:
-(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