是什么导致Xcode 8.3中的AppDelegate文件出现“SIGABRT”错误?

时间:2017-04-19 17:21:33

标签: swift3 sigabrt xcode8

@UIApplicationMain class AppDelegate:UIResponder,UIApplicationDelegate {//主题1:信号SIGABRT

var window: UIWindow?

“线程1:信号SIGABRT”位于“class”行的末尾。

内容 用户输入膳食小计,小费百分比和税率;并且该计划输出税额,小费金额和膳食总费用。这是一个简单的单视图程序。我没有对AppDelegate文件进行任何更改。所有代码都添加到ViewController文件中。

AppDelegate文件中没有其他错误。 ViewController文件中有几个警告,但没有错误。在运行时,模拟器(iPhone 7)显示但是为空。 CONSOLE OUTPUT位于ViewController的代码之后。

ViewController代码:

import UIKit

class ViewController: UIViewController, UITextFieldDelegate {
    @IBOutlet var txtMealCost: UITextField!
    @IBOutlet var txtTipPercent: UITextField!
    @IBOutlet var txtTaxRatePercent: UITextField!
    @IBOutlet weak var lblTaxAmt: UILabel!
    @IBOutlet weak var lblTipAmt: UILabel!
    @IBOutlet weak var lblTotalCost: UILabel!

/*    var mealCost = Double(txtMealCost.text)
    var tipPercent : Float = 0
    var taxRatePercent : Float = txtTaxRatePercent.text
    var taxAmt : Float = 0
    var tipAmt : Float = 0
    var totalCost : Float = 0
    var totalCost = mealCost + taxAmt + tipAmt
*/
    @IBAction func btnCalculate(_ sender: UIButton) {
        var mealCost = Double(txtMealCost.text!)!
        var tipPercent = Double(txtTipPercent.text!)!
        var taxRatePercent = Double(txtTaxRatePercent.text!)!
        var taxAmt = mealCost * taxRatePercent
        var lblTaxAmt = String(taxAmt)
        var tipAmt = mealCost * tipPercent
        var lblTipAmt = String(lblTipAmt)
        var totalCost = mealCost + taxAmt + tipAmt
        var lblTotalCost = String(totalCost)

/*        var fMealCost = (mealCost as NSString).floatValue
        var fTipPercent = tipPercent
        var fTaxRatePercent = taxRatePercent
        var fTaxAmt = taxAmt
        var fTipAmt = tipAmt
*/   //     var fTotalCost = totalCost
        }
    @IBAction func Clear(_ sender: UIButton) {
    txtMealCost.text = ""
    txtTipPercent.text = ""
    txtTaxRatePercent.text = ""
    lblTaxAmt.text = ""
    lblTipAmt.text = ""
    lblTotalCost.text = ""
    }
    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.
        }
}

CONSOLE OUTPUT: 2017-04-19 14:10:54.720 MealCostCalculator [1932:96055] *由于未捕获的异常'NSUnknownKeyException'终止应用程序,原因:'[setValue:forUndefinedKey:]:此类不符合键值编码关键的MealCost。' * 第一次抛出调用堆栈: (     0 CoreFoundation 0x000000010ccf4b0b exceptionPreprocess + 171     1 libobjc.A.dylib 0x000000010a085141 objc_exception_throw + 48     2 CoreFoundation 0x000000010ccf4a59 - [NSException raise] + 9     3基础0x0000000109b9ae8b - [NSObject(NSKeyValueCoding)setValue:forKey:] + 292     4 UIKit 0x000000010a6f2644 - [UIViewController setValue:forKey:] + 87     5 UIKit 0x000000010a95f6b9 - [UIRuntimeOutletConnection connect] + 109     6 CoreFoundation 0x000000010cc9ae8d - [NSArray makeObjectsPerformSelector:] + 269     7 UIKit 0x000000010a95e06f - [UINib instantiateWithOwner:options:] + 1856     8 UIKit 0x000000010a6f8c73 - [UIViewController _loadViewFromNibNamed:bundle:] + 381     9 UIKit 0x000000010a6f9589 - [UIViewController loadView] + 177     10 UIKit 0x000000010a6f98ba - [UIViewController loadViewIfRequired] + 195     11 UIKit 0x000000010a6fa10a - [UIViewController视图] + 27     12 UIKit 0x000000010a5c263a - [UIWindow addRootViewControllerViewIfPossible] + 65     13 UIKit 0x000000010a5c2d20 - [UIWindow _setHidden:forced:] + 294     14 UIKit 0x000000010a5d5b6e - [UIWindow makeKeyAndVisible] + 42     15 UIKit 0x000000010a54f31f - [UIApplication _callInitializationDelegatesForMainScene:transitionContext:] + 4346     16 UIKit 0x000000010a555584 - [UIApplication _runWithMainScene:transitionContext:completion:] + 1709     17 UIKit 0x000000010a552793 - [UIApplication workspaceDidEndTransaction:] + 182     18 FrontBoardServices 0x000000010e4045f6 __FBSSERIALQUEUE_IS_CALLING_OUT_TO_A_BLOCK + 24     19 FrontBoardServices 0x000000010e40446d - [FBSSerialQueue _performNext] + 186     20 FrontBoardServices 0x000000010e4047f6 - [FBSSerialQueue _performNextFromRunLoopSource] + 45     21 CoreFoundation 0x000000010cc9ac01 CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION + 17     22 CoreFoundation 0x000000010cc800cf __CFRunLoopDoSources0 + 527     23 CoreFoundation 0x000000010cc7f5ff __CFRunLoopRun + 911     24 CoreFoundation 0x000000010cc7f016 CFRunLoopRunSpecific + 406     25 UIKit 0x000000010a55102f - [UIApplication _run] + 468     26 UIKit 0x000000010a5570d4 UIApplicationMain + 159     27 MealCostCalculator 0x0000000109aa9487 main + 55     28 libdyld.dylib 0x000000010dc9465d start + 1     29 ??? 0x0000000000000001 0x0 + 1 ) libc ++ abi.dylib:以NSException类型的未捕获异常终止 (LLDB)enter code here

0 个答案:

没有答案