-1

I am new to Swift, and I am trying to develop a quiz app. When I try to load the app on my iPhone, i get this error of SIGABRT in the AppDelegate class, and then there is just a white screen on the phone. How can I fix this? I have already tried to clean the code, and I erased and checked carefully the links that i have between the buttons and the code (as suggested in another question with those answers), and I still get this error.

below is my view class

import UIKit
import Foundation

class ViewController: UIViewController {


    override func viewDidLoad() {
        super.viewDidLoad()
        updateQuestion()
    }

    //Label
    @IBOutlet weak var label: UILabel!
    @IBOutlet weak var scorelabel: UILabel!
    @IBOutlet weak var flagview: UIImageView!

    //Botones
    @IBOutlet var botona: UIButton!

    @IBOutlet var botonb: UIButton!

    @IBOutlet var botonc: UIButton!

    @IBOutlet var botond: UIButton!

    let allQuestions = QuestionBank()
    var questionNumber: Int = 0
    var score: Int = 0
    var selectedAnswer: Int = 0

    //Button
    @IBAction func boton(_ sender: UIButton) {
        if sender.tag == selectedAnswer {
            print("Correcto")
            score+=1
        }
        else {
         print("Incorrecto")
        }
        updateQuestion()
    }

    func updateQuestion(){
    flagview.image=UIImage(named:allQuestions.list[questionNumber].questionImage)
        label.text=allQuestions.list[questionNumber].question

        botona.setTitle(allQuestions.list[questionNumber].optionA, for: UIControlState.normal)

        botonb.setTitle(allQuestions.list[questionNumber].optionB, for: UIControlState.normal)

        botonc.setTitle(allQuestions.list[questionNumber].optionC, for: UIControlState.normal)

        botond.setTitle(allQuestions.list[questionNumber].optionD, for: UIControlState.normal)

        selectedAnswer = allQuestions.list[questionNumber].correctAnswer

        questionNumber += 1
    }

    func updateUI(){

    }

    func restartQuiz(){

    }


    override func didReceiveMemoryWarning() {
        super.didReceiveMemoryWarning()
        // Dispose of any resources that can be recreated.
    }

Any help would REALLY be appreciated! Thank you in advance.

  • Most likely you have broke a connection between an `IBOulet`. Did you rename an outlet and not remove the old link and reconnect it? – MwcsMac Mar 14 '18 at 00:50
  • I did rename a button, how can I keep track of the current and old links? – miriamfemerling Mar 14 '18 at 00:51
  • Possible duplicate of [Swift error : signal SIGABRT how to solve it](https://stackoverflow.com/questions/43546497/swift-error-signal-sigabrt-how-to-solve-it) – Mohammad Kanan Mar 14 '18 at 00:56

2 Answers2

1

It would be good to have a look what your Xcode console logs are saying. Usually, there is a information in the logs if any outlet has a broken link.

Also to answer your question on how to track of the current and old links, in Xcode, against your IBOutlets and IBAction, there is a dot at the left. If it is filled, it means, the outlet and action is linked properly.

IBoutlet linked

Be mindful, sometimes there are Xcode issues and these circles are not shown properly. Just click once on relevant storyboard and then click back on the viewController file, all your links will be reflecting properly.

Deepika
  • 438
  • 3
  • 6
  • 2018-03-13 18:59:30.581221-0600 LabsFisica[19849:1694359] *** Terminating app due to uncaught exception 'NSUnknownKeyException', reason: '[ setValue:forUndefinedKey:]: this class is not key value coding-compliant for the key boton.' *** First throw call stack: ( 0 CoreFoundation 0x0000000111a9c12b __exceptionPreprocess + 171 1 libobjc.A.dylib 0x000000010dda8f41 objc_exception_throw + 48 2 CoreFoundation 0x0000000111a9c079 - – miriamfemerling Mar 14 '18 at 01:00
  • As i can guess from the code your have shared and the crash report, you have a button linked to a IBOutlet boton which is no more there (as you may have renamed it). You need to delete the existing connection for that button and re-connect it to the renamed IBOutlet – Deepika Mar 14 '18 at 01:15
0

The SIGABRT indicates that the app called abort() (a delibarated crash). To know more about the issue you can add a exception breakpoint. To do this you need go to the Breakpoint navigator, click on the ’+’ button and ’Add Exception Breakpoint’

To learn more about the available debug tools I sugget you to read Apple's Debug tool documentation

Enrique Bermúdez
  • 1,740
  • 2
  • 11
  • 25