使用 Typhoon 和 swift 注入从 UIStoryboard 实例化的 UIViewController 的正确方法是什么?
我在任何一个示例应用程序中都找不到任何明确的示例,当我从文档中翻译 Objective C 代码时,它会引发异常。
以下是我的 AppAssembly 中的代码:
public dynamic func loginViewController() -> LoginViewController {
return TyphoonDefinition.withClass(LoginViewController.self) {
(definition) in
definition.injectProperty("socialClient",with:self.coreComponents.socialClient())
//definition.scope = TyphoonScope.Singleton
} as LoginViewController
}
这是抛出的异常:
0x10636ca1c: jne 0x10636ca10 ; swift_dynamicCastClassUnconditional + 48
0x10636ca1e: leaq 0x36b3d(%rip), %rax ; "Swift dynamic cast failed"
0x10636ca25: movq %rax, 0xb4a2c(%rip) ; gCRAnnotations + 8
0x10636ca2c: int3
0x10636ca2d: movq %rdi, %rax
0x10636ca30: popq %rbp
0x10636ca31: retq
0x10636ca32: nopw %cs:(%rax,%rax)
“Swift 动态转换失败”让我相信,使用 Objective C 可能的事情在使用 Swift 时是不可能的。
有没有人能够完成这项工作?任何帮助将不胜感激。该库看起来非常好,我真的很想使用它。