I have a TableView with Persons. When I tap on a cell it performs a seque to another view.
Searching works. But when I search, cancel, tap on one cell, go back and want to search again, it crashes. EXC_BAD_INSTRUCTION.
func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell
{
var cell = UITableViewCell()
if let sdc = self.searchDisplayController {
if sdc.active {
if let c: AnyObject? = self.tableView.dequeueReusableCellWithIdentifier("CellPerson"){
cell = c as UITableViewCell
cell.textLabel.text = personsFiltered[indexPath.row]!
}
else
{
cell = UITableViewCell(style: UITableViewCellStyle.Subtitle, reuseIdentifier: "Cell")
}
} else {
if let c: AnyObject? = self.tableView.dequeueReusableCellWithIdentifier("CellPerson"){
cell = c as UITableViewCell
cell.textLabel.text = persons[indexPath.row]!
}
else
{
cell = UITableViewCell(style: UITableViewCellStyle.Subtitle, reuseIdentifier: "Cell")
}
}
return cell
}