添加新的View Controller时,Swift动态转换失败

时间:2014-11-04 10:46:23

标签: ios swift

我在swift中有一个简单的iOS测试应用程序。我在故事板的开头添加了一个额外的View Controller并创建了一个类LoginViewController:UIViewController我将我的View Controller设置为自定义类LoginViewController并更改了属性以使其成为初始视图控制器。

我还添加了一个简单的按钮,这是我对应用程序其余部分的支持。

现在,当我在模拟器中启动我的应用程序时,它会立即崩溃:

libswiftCore.dylib`swift_dynamicCastClassUnconditional:
0x10cc3f9e0:  pushq  %rbp
0x10cc3f9e1:  movq   %rsp, %rbp
0x10cc3f9e4:  testq  %rdi, %rdi
0x10cc3f9e7:  je     0x10cc3fa1e               ; swift_dynamicCastClassUnconditional + 62
0x10cc3f9e9:  movabsq $-0x7fffffffffffffff, %rax
0x10cc3f9f3:  testq  %rax, %rdi
0x10cc3f9f6:  jne    0x10cc3fa1e               ; swift_dynamicCastClassUnconditional + 62
0x10cc3f9f8:  leaq   0xb5109(%rip), %rax
0x10cc3f9ff:  movq   (%rax), %rax
0x10cc3fa02:  andq   (%rdi), %rax
0x10cc3fa05:  nopw   %cs:(%rax,%rax)
0x10cc3fa10:  cmpq   %rsi, %rax
0x10cc3fa13:  je     0x10cc3fa2d               ; swift_dynamicCastClassUnconditional + 77
0x10cc3fa15:  movq   0x8(%rax), %rax
0x10cc3fa19:  testq  %rax, %rax
0x10cc3fa1c:  jne    0x10cc3fa10               ; swift_dynamicCastClassUnconditional + 48
0x10cc3fa1e:  leaq   0x36b3d(%rip), %rax       ; "Swift dynamic cast failed"
0x10cc3fa25:  movq   %rax, 0xb4a2c(%rip)       ; gCRAnnotations + 8
0x10cc3fa2c:  int3   
0x10cc3fa2d:  movq   %rdi, %rax
0x10cc3fa30:  popq   %rbp
0x10cc3fa31:  retq   
0x10cc3fa32:  nopw   %cs:(%rax,%rax)

我显然错过了一个简单的步骤,只是不知道它是什么!

1 个答案:

答案 0 :(得分:0)

我收到了以下错误:

swift_dynamicCastClassUnconditional

Swift动态演员失败

问题代码:每次连接到不同的segue

时,我都在使用CredentialsSetting ViewController
 // programming mark ----- ----- ---- ----- ----- ---- ----- ----- ----

    override func prepareForSegue(segue: UIStoryboardSegue, sender: AnyObject!) {

            var detailController = segue.destinationViewController as CredentialsSetting;
            detailController.viewControllerType = self.viewControllerType


    }// end prepareForSegue

解决方案:为了解决这个问题,我已经为不同的连接添加了传输segue的特定条件:

 // programming mark ----- ----- ---- ----- ----- ---- ----- ----- ----

    override func prepareForSegue(segue: UIStoryboardSegue, sender: AnyObject!) {


        if self.viewControllerType == "donothavepassword" || self.viewControllerType == "forgotpassword"  {

            var detailController = segue.destinationViewController as CredentialsSetting;
            detailController.viewControllerType = self.viewControllerType


        }


    }// end prepareForSegue