![](/img/trans.png)
[英]Swift compiler error after upgrade xcode 6 beta 6 to xcode 6 GM seed
[英]Strange compilation error after I upgrade to Xcode-beta 7
這是我的代碼。
var indexPath = self.tableView.indexPathForCell(cell)
self.tableView.beginUpdates()
self.tableView.reloadRowsAtIndexPaths([indexPath], withRowAnimation:.Automatic)
self.tableView.endUpdates()
我收到以下編譯錯誤:
使用未解決的標識符“自動”
我嘗試了UITableViewAnimation.Automatic。 但是也失敗了。
它出什么問題了? 謝謝。
該錯誤信息是令人誤解的。 在Xcode 6 beta 7中, indexPathForCell()
返回一個optional ,因此您必須解開它或使用條件賦值:
if let indexPath = self.tableView.indexPathForCell(cell) {
self.tableView.beginUpdates()
self.tableView.reloadRowsAtIndexPaths([indexPath], withRowAnimation: .Automatic)
self.tableView.endUpdates()
}
(請注意,如果僅更新一行,則實際上不需要調用begin/EndUpdates
。)
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.