我正在尝试Typhoon
使用 PList 集成方法进行引导,但我ApplicationDelegate
正在创建两次。第一次创建时,显然是由Typhoon
. 那时,它使用特殊的初始化程序initWithAssembly:
并将Typhoon
程序集提供给它。
第二次,重要的时间,它是使用init
. 它永远不会获得对程序集的引用。
以防万一,我还注入了assembly
via 属性方法。不去。
这是代码:
集会
- (UIApplication *)sharedApplication {
return [TyphoonDefinition withClass:[UIApplication class] configuration:^(TyphoonDefinition *definition) {
[definition useInitializer:@selector(sharedApplication)];
}];
}
- (CTISApplicationDelegate *)appDelegate {
return [TyphoonDefinition withClass:[CTISApplicationDelegate class]
configuration:^(TyphoonDefinition *definition) {
[definition useInitializer:@selector(initWithAssembly:) parameters:^(TyphoonMethod *initializer) {
[initializer injectParameterWith:@(3)];
}];
definition.scope = TyphoonScopeSingleton;
}];
}
应用委托
@property (nonatomic, strong, readwrite) ApplicationAssembly *assembly;
@property (nonatomic, strong, readwrite) UIWindow *window;
- (instancetype)initWithAssembly:(ApplicationAssembly *)assembly;
...
// This gets called once, the first time, and assembly is NOT nil.
- (instancetype)initWithAssembly:(ApplicationAssembly *)assembly {
self = [super init];
if (self) {
self.assembly = assembly;
}
return self;
}
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] applicationFrame]];
// This gets ca
填充一次(在第二次初始化之后)并且 self.assembly 为零。
AcceptDisclaimerAppInfoModule *disclaimer = [[self.assembly applicationInformationModuleAssembly] acceptDisclaimerModule];
[disclaimer launchModuleFromWindow:self.window];
[self.window makeKeyAndVisible];
return YES;
}