I have just evolved my search Table View Cell
(added more labels etc). But now when I run the new code, a random Signal SIGABRT
crashes the app. The old version looked like this (and works properly):
override func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell {
let cell = tableView.dequeueReusableCellWithIdentifier("cell", forIndexPath: indexPath) as UITableViewCell?
if self.resultSearchController.active
{
cell!.textLabel?.text = self.filteredQuotes[indexPath.row].quote
cell!.detailTextLabel?.text = self.filteredQuotes[indexPath.row].person
}
else
{
cell!.textLabel?.text = self.quotes[indexPath.row].quote
cell!.detailTextLabel?.text = self.quotes[indexPath.row].person
}
return cell!
}
The new code (including new features/data). I have changed the cell to a custom cell with an own swift file, named SearchCell. It includes only the cell's outlets. Followed this answer https://stackoverflow.com/a/30776750/5274566
override func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell {
let cell = tableView.dequeueReusableCellWithIdentifier("ChoosenCell", forIndexPath: indexPath) as! SearchCell
if self.resultSearchController.active
{
cell.quoteLabel?.text = self.filteredQuotes[indexPath.row].quote
cell.personLabel?.text = self.filteredQuotes[indexPath.row].person
cell.WikiLabel?.text = self.filteredQuotes[indexPath.row].wikiLink
cell.OccupationLabel?.text = self.filteredQuotes[indexPath.row].Occupation
cell.LifeLabel?.text = self.filteredQuotes[indexPath.row].life
cell.NationLabel?.text = self.filteredQuotes[indexPath.row].Nation
cell.PersonImageView?.image = self.filteredQuotes[indexPath.row].image
}
else
{
cell.quoteLabel?.text = self.quotes[indexPath.row].quote
cell.personLabel?.text = self.quotes[indexPath.row].person
cell.WikiLabel?.text = self.quotes[indexPath.row].wikiLink
cell.OccupationLabel?.text = self.quotes[indexPath.row].Occupation
cell.LifeLabel?.text = self.quotes[indexPath.row].life
cell.NationLabel?.text = self.quotes[indexPath.row].Nation
cell.PersonImageView?.image = self.quotes[indexPath.row].image
}
return cell
}
I have been trying the find the missing link for a outlet for days now, but can't understand it at all. The app crashes when I'm trying to open the Table View and the error says to occurs in the AppDelegate
file at first.
I have checked all the outlets
, actions
, identifiers
(and changed some to the correct and new ones) etc in the Storyboard
and there are no errors there (I even compared the old version to the new = they are identical).
I have tried to search deeper using the debugger, following this useful tutorial https://www.raywenderlich.com/10209/my-app-crashed-now-what-part-1 . The result is this breakpoint in the new code:
Now I have been searching for a possible solution to this code, which seems absolutely fine (no errors) and have worked for others. I'm new to programmering so all help is very much appreciated.