當我試圖運行此代碼時,出現錯誤「在它自己的初始值內使用的變量」。什麼導致這個錯誤?有錯誤「在它自己的初始值內使用的變量」
var pagetitle = ""
var alertActionButtons = [UIAlertAction]()
var okAction = UIAlertAction(title: pagetitle, style: .Default) { action in
self.presentingViewController!.dismissViewControllerAnimated(false) {
self.unitDetailProtocolVar!.closeUnitDetail()
}
}
alertActionButtons.append(okAction)
self.alert = self.controllerUtil.customAlert(pagetitle, buttons: alertActionButtons, alertMessage: alertMessage)
我看到你編輯了這個問題,以包括缺少的大括號。它仍然給你同樣的錯誤?如果是這樣,請檢查遞歸方法調用。此代碼是否寫入dismissViewControllerAnimated或closeUnitDetail? – bgolson