2016-04-22 65 views
0

不能與雨燕2.2,版本的Xcode 7.3(7D175)雨燕 「守衛讓」 解包失敗

「錦衣衛讓」 解包可選類型失敗 "guard let" failed

但 「衛變種」 的作品 But "guard let" works

請幫忙! 這是怎麼回事?

EDIT1

let localPresenter = presenter 
    let localDataSource = dataSource 
    let configurator: ViewControllerConfigurator = { inputView in 
     let a = inputView as? ChatTableViewController 
     guard var chatListController = a else { 
      throw ApplicationErrors.ModuleConfigureError.WrongViewInput 
     } 
     localPresenter.view = chatListController 
     chatListController.presenter = localPresenter 
     chatListController.tableView.dataSource = localDataSource 
    } 

EDIT2 此代碼工作正常:

 let localPresenter = presenter 
     let localDataSource = dataSource 
     let configurator: ViewControllerConfigurator = { inputView in 
      let a = inputView as? ChatTableViewController 
      if let chatListController = a { 
       localPresenter.view = chatListController 
       chatListController.presenter = localPresenter 
       chatListController.tableView.dataSource = localDataSource 
      } else { 
       throw ApplicationErrors.ModuleConfigureError.WrongViewInput 
      } 
     } 
+2

請還包括你的代碼**作爲文本**(使用[編輯]按鈕)。 – Moritz

+0

對不起,我無法創建一個簡單的示例項目。 – adnako

+0

@EricD謝謝,我知道,但問題不在於斷點。我無法弄清楚爲什麼衛兵很好地解開變量,但它不能解開一個常量? – adnako

回答

0

看起來它是在LLDB的錯誤。 如果我設置斷點與「後衛」行了,然後「錦衣衛」失敗: enter image description here

但如果我提出這個斷點過去保護塊的代碼工作正常: enter image description here

+0

這不是一個錯誤,它是如何工作的。 :)斷點是一個障礙,一個停止標誌:執行運行*直到它遇到斷點*所以如果你把stop *放在一行上,應用程序會在這行之前暫停*。 – Moritz

+0

我很抱歉,但爲什麼它以這種方式工作,當我設置斷點代碼失敗?讀什麼關於他的行爲?我知道過去的斷點是IRQ在指令上停止CPU,但看起來像是在這裏發生了一些寄存器值,因此代碼工作不正確。不是嗎? – adnako

+0

在物理學中它被稱爲「觀察者效應」。 – adnako