2014-11-04 52 views
1

我有一個簡單的iOS測試應用程序在swift中。我在故事板的開頭添加了一個額外的視圖控制器,並創建了一個LoginViewController類:UIViewController我已將View Controller設置爲自定義類LoginViewController,並更改了屬性以使其成爲初始視圖控制器。添加新的視圖控制器時Swift dynamic cast失敗

我還添加了一個簡單的按鈕,這是我的應用程序的其餘部分。

現在,當我開始我的應用程序在模擬器,它立即用下面的崩潰:

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) 

我顯然錯過了一個簡單的一步,只是不知道它是什麼!

回答

0

我得到以下錯誤:

swift_dynamicCastClassUnconditional

斯威夫特動態轉換失敗

問題代碼:我用CredentialsSetting視圖控制器每次當連接到不同的賽格瑞

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

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

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


    }// end prepareForSegue 

解決方案:爲了解決這個問題,我添加了特定的條件來傳遞不同的連接ns:

// 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 
相關問題