參數我在從一個視圖控制器一個textFieldShouldReturn
手動調用cellForRowAtindexPath
,以及用於cellForRowAtindexPath
參數都是tableViewOutlet
和indexPath
(在這個例子中「索引」)。這裏的cellForRowAtindexPath
和tableViewOutlet
都來自另一個視圖控制器,我使用實例調用它們。傳遞的tableview出口中的cellForRowAtIndexPath
一旦cellForRowAtindexPath
調用它顯示錯誤,如:
unexpectedly found nil while unwrapping an optional value.
func textFieldShouldReturn(_ textField: UITextField) -> Bool {
textField.resignFirstResponder()
if(textField == carRating){
let rating = Float(textField.text!)
secondInstanceForMyData.masterCarData[index.row].carRating = rating
let _: MyTableViewCell = myViewControllerInstance.tableView(myViewControllerInstance.tableViewWillLoad as UITableView, cellForRowAt: index) as! MyTableViewCell
}
return true
}
可能的重複[什麼是「致命錯誤:意外地發現零,而解包可選值」是什麼意思?](https://stackoverflow.com/questions/32170456/what-does-fatal-error-unexpectedly-found- nil-while-unwrapping-an-optional-valu) – the4kman
表示從我們提取的變量中沒有數據變量 – Harsha
以'let _:MyTableViewCell = ...'開頭的行的要點是什麼? – rmaddy