Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

iOS Swift Basics (retired) Control Flow Exercise: FizzBuzz Generator

Ricard Pons
Ricard Pons
3,082 Points

I get SIGABRT error when hitting Fizz button in order to increment score if True

I am not able to find the error with breakpoints and I tried everything. This is my code:

class ViewController: UIViewController {

    var score = 0
    var number = 1
    @IBOutlet weak var numberLabel: UILabel!
    @IBOutlet weak var scoreLabel: UILabel!

    override func viewDidLoad() {
        super.viewDidLoad()

        scoreLabel.text = "Score \(score)"
        numberLabel.text = "\(number)"
    }

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

    @IBAction func fizzButton() {

        if fizzResult() == true { scoreLabel.text = "Score \(number + 1)" } else { print("nope") }
    }

    func fizzResult() -> Bool {
        if number % 3 == 0 { return true } else { return false }
    }
}

2 Answers

Hi Ricard,

Have you checked your storyboard for orphan connections? That causes that error, among other things.

Steve.

Ricard Pons
Ricard Pons
3,082 Points

Thank you for the response Steve,

Yes, I have checked that, but the button and labels seem to be OK.

Not sure that I can see anything wrong in your code to throw that error. I'll give it a go on the Mac, but without the whole project that's not going to help much as the problem may not lie within the code you've posted.

Do you have a Github account you can push your project up to?

Steve.

Ricard Pons
Ricard Pons
3,082 Points

Sorry I've been busy these days. I'll write the code again in a new project when I arrive to the office. I don't have a Github account, so if the code fails again i'll create one to upload the project. Thank you Steve.