1

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: enter image description here

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.

Community
  • 1
  • 1
Mate
  • 99
  • 10
  • Is the cell identifier `ChoosenCell` correct? Have you registered your `SearchCell` custom cell? Normally, SIGABRT means null pointer access. Debug step over that line and try to trace the reason for connection missing between property and IBOutlet. – x4h1d Aug 22 '16 at 14:34
  • Are you using StoryBoard or code? – MCMatan Aug 22 '16 at 14:51
  • Yes, they are both right - that's the weird part! What's the best way to debug and trying to trace the reason? How should I do? @x4h1d – Mate Aug 22 '16 at 15:57
  • I'm using both - I followed this easy and simple tutorial http://stackoverflow.com/a/30776750/5274566 @MCMatan – Mate Aug 22 '16 at 15:58
  • Is your class a subclass of SearchCell? Do you have a sample project? – MCMatan Aug 22 '16 at 16:01
  • While debugger stops at that point, press `F6` (or `fn+F6`) until you get the crash. When you face the crash, in log console you will see some logs. check those, if possible add console logs in the question. – x4h1d Aug 22 '16 at 16:12

2 Answers2

0

You most likely have a breakpoint in your code. If there is a blue shape on the left of the line (as shown below), tap on it to deactivate it.

Breakpoint:

Breakpoint

Deactivated breakpoint:

removed

Community
  • 1
  • 1
Pranav Wadhwa
  • 7,666
  • 6
  • 39
  • 61
0

This was really weird. After searching and searching for the error I gave up and decided do delete the whole custom cell and recreate it all - it worked perfectly. I guess there were some old garbage stuck somewhere with the old cell.

Thank you all so much for your help and please keep up the good work - it means the world to beginners as myself!

Mate
  • 99
  • 10