当我开始更新表视图(下拉刷新),然后突然开始翻转列表时,应用程序崩溃。Swift - TableView上的应用程序崩溃UIRefreshControl
fatal error: Cannot index empty buffer
func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell {
let cell = tableView.dequeueReusableCellWithIdentifier("BankCell", forIndexPath: indexPath) as BankTableViewCell
cell.backgroundColor = UIColor(red: 241/255, green: 233/255, blue: 220/255, alpha: 1.0)
let bank:Bank = self.allRates[indexPath.row] as Bank // <-- Error here
cell.titleLabel.text = bank.name
return cell
}
大概我要检查阵列中的元件的存在。但是这是正确的出路吗?
- 我编辑列#2:
let cell = tableView.dequeueReusableCellWithIdentifier("BankCell") as BankTableViewCell
但错误依然存在。
我的刷新功能:
func refresh(sender:AnyObject)
{
parser.deleteObjects()
self.allRates.removeAll(keepCapacity: false)
parser.parse { // - XMLParser ended to Parse file
self.allRates = self.parser.actualBankRates + self.parser.notActualBankRates
self.tableView.reloadData()
self.refreshController.endRefreshing()
}
}
在XMLParser的:
var actualBankRates = [Bank]()
var notActualBankRates = [Bank]()
在下拉刷新并重新载入更新的数据后会崩溃吗? – rakeshbs