我有一个UITableview
包含搜索栏的搜索栏,我的过滤器一切正常。当我单击一个单元格将值传递给另一个单元格UIViewController
并同时打开它UIViewController
时,一切仍然正常。但我的问题是,当我单击后退按钮返回 时UITableViewController
,我收到此错误:
数组索引超出范围
从这行代码:
cell.textLabel?.text = filtered[indexPath.row]
这是我的所有代码:
override func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell
{
let cell = tableView.dequeueReusableCellWithIdentifier("Cell") as UITableViewCell;
if(searchActive){
cell.textLabel?.text = filtered[indexPath.row]
} else {
var aaa = posts1.objectAtIndex(indexPath.row).valueForKey("speedKPH") as NSString
let speeddouble = NSString(string: aaa).intValue
var aa = String(speeddouble)
var bb = posts1.objectAtIndex(indexPath.row).valueForKey("timestamp") as NSString
var now = (NSDate(timeIntervalSince1970:(bb as NSString).doubleValue))
var formatter = NSDateFormatter()
formatter.dateFormat = "dd-MM-yyyy' 'HH:mm' '"
formatter.timeZone = NSTimeZone(forSecondsFromGMT: 0)
cell.textLabel?.text = posts.objectAtIndex(indexPath.row).valueForKey("description") as NSString + "\n"+"Velocidad : " + aa+" KM/H / Ult. Act. :" + formatter.stringFromDate(now)
cell.detailTextLabel?.text = posts.objectAtIndex(indexPath.row).valueForKey("deviceID") as NSString
}
SwiftSpinner.hide()
return cell;
}
} 请帮忙!