E
E
E Happy2016-08-30 19:21:29
Apple Xcode
E Happy, 2016-08-30 19:21:29

How to fix error in XCode (Thread 1: SIGABRT)?

I started making an application for the first time according to the guide, I compile it, test it - an error pops up

class AppDelegate: UIResponder, UIApplicationDelegate {
"Thread 1: signal SIGABRT" and the application does not even open (which is not strange in general).
Application for calculating body mass index. I set the windows, I set the connection with them.
//
//  FirstViewController.swift
//  Mass App
//
//  Created by *** on 30.08.16.
//  Copyright © 2016 ***. All rights reserved.
//

import UIKit

class FirstViewController: UIViewController {
    
    
    
    @IBOutlet weak var ageTextField: UITextField!
    @IBOutlet weak var heightTextField: UITextField!
    @IBOutlet weak var weightTextField: UITextField!
    @IBOutlet weak var sexSegmentedControl: UISegmentedControl!
    @IBOutlet weak var activitySegmentedControl: UISegmentedControl!
    @IBOutlet weak var resultsLabel: UILabel!
    @IBAction func calculateTapped(sender: AnyObject)
    {
        weak var activitySegmentedControl: UISegmentedControl!
        func calculateTapped(sender: AnyObject) {
            var bmr: Double = 0
            var bmi: Double = 0
            
            if let age = Int(ageTextField.text!) {
                if let height = Int(heightTextField.text!) {
                    if let weight = Int(weightTextField.text!) {
                        switch sexSegmentedControl.selectedSegmentIndex {
                        case 0:
                            bmr = 88.362 + 13.397 * Double(weight) + 4.799 * Double(height) - 5.677 * Double(age)
                        case 1:
                            bmr = 447.593 + 9.247 * Double(weight) + 3.098 * Double(height) - 4.330 * Double(age)
                        default:
                            bmr = 0
                        }
                        bmi = Double(weight) / pow(Double(height) / 100, 2)
                    }
                }
            }
            
            let factor = [1.375, 1.55, 1.725, 1.9]
            let selectedFactor = factor[activitySegmentedControl.selectedSegmentIndex]
            bmr *= selectedFactor
            resultsLabel.text? = "Вы должны потреблять \(Int(bmr)) килокалорий для поддержания веса.\nИндекс массы тела \(Int(bmi))."
            
            UIApplication.sharedApplication().keyWindow!.endEditing(true)
            
        }
        
    }
    
    
    override func viewDidLoad() {
        
        super.viewDidLoad()
        // Do any additional setup after loading the view, typically from a nib.
    }
    
    override func didReceiveMemoryWarning() {
        super.didReceiveMemoryWarning()
        // Dispose of any resources that can be recreated.
    }
    
    
}

Mistake:
2016-08-30 19:05:45.409 Mass App[4618:118258] *** Terminating app due to uncaught exception 'NSUnknownKeyException', reason: '[<Mass_App.FirstViewController 0x7c88dbc0> setValue:forUndefinedKey:]: this class is not key value coding-compliant for the key activityTextField.'

I suppose that the error is that before that, instead of activitySegmentedControl, I wrote activityTextField.
Where is it left and does not start? Or what?..

Answer the question

In order to leave comments, you need to log in

2 answer(s)
V
Vyacheslav Beltyukov, 2016-08-31
@EHappy

In case of such problems, you need to do Product -> Clean (Shift + Cmd + K)
If it doesn’t help, you need to delete Derived data, this can be done by opening Window -> Projects and selecting your project

E
E Happy, 2016-08-30
@EHappy

I solved the problem by simply redoing the project 1 in 1.
Either a system glitch, or an error that I spoke about.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question