【问题标题】:Thread:1 Signal SIGAGBRT线程:1 信号 SIGAGBRT
【发布时间】:2017-01-30 22:32:36
【问题描述】:

为什么我会在此代码中获得 Thread:1 Signal SIGAGBRT?我不知道要更改什么来修复错误。应用程序启动,一旦我按下按钮,应用程序就会取消并给我一个错误。

import UIKit

class ViewController: UIViewController {

    @IBOutlet var textFieldInput: UITextField!
    @IBOutlet var laCelsius: UILabel!
    @IBOutlet var laFahrenheit: UILabel!

    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.
    }


    @IBAction func btn(sender: UIButton) {

        var c_out = 0.0
        var f_out = 0.0
        var inputValue = 0.0

        let textInput = NSString(string: textFieldInput.text!)
        inputValue = textInput.doubleValue

        c_out = (inputValue-32)*5/9
        f_out = inputValue * 1.8 + 32

        self.laCelsius.text = NSString(format: "%3.2f" ,c_out) as String
        self.laFahrenheit.text = NSString(format: "%3.2f" ,f_out) as String

    }

}

这是错误代码:

2016-09-22 14:15:51.669 DegreeCL[19045:1774964]-[DegreeCL.ViewController btnPressed:]:无法识别的选择器发送到实例 0x7fa7bb643d40 2016-09-22 14:15:51.674 DegreeCL [19045:1774964] *** 由于未捕获的异常“NSInvalidArgumentException”而终止应用程序,原因:“-[DegreeCL.ViewController btnPressed:]:无法识别的选择器发送到实例 0x7fa7bb643d40” *** 首先抛出调用堆栈: ( 0 核心基础 0x000000010de1dd85 __exceptionPreprocess + 165 1 libobjc.A.dylib 0x000000010fbc1deb objc_exception_throw + 48 2核心基础0x000000010de26d3d-[NSObject(NSObject)不识别选择器:]+205 3 核心基础 0x000000010dd6ccfa ___forwarding___ + 970 4 核心基础 0x000000010dd6c8a8 _CF_forwarding_prep_0 + 120 5 UIKit 0x000000010e647a8d-[UIApplication sendAction:to:from:forEvent:] + 92 6 UIKit 0x000000010e7bae67-[UIControl sendAction:to:forEvent:] + 67 7 UIKit 0x000000010e7bb143-[UIControl_sendActionsForEvents:withEvent:] + 327 8 UIKit 0x000000010e7ba263-[UIControl touchesEnded:withEvent:] + 601 9 UIKit 0x000000010e6ba99f-[UIWindow_sendTouchesForEvent:] + 835 10 UIKit 0x000000010e6bb6d4 -[UIWindow 发送事件:] + 865 11 UIKit 0x000000010e666dc6 -[UIApplication 发送事件:] + 263 12 UIKit 0x000000010e640553 _UIApplicationHandleEventQueue + 6660 13 核心基础 0x000000010dd43301 __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION__ + 17 14 核心基础 0x000000010dd3922c __CFRunLoopDoSources0 + 556 15 核心基础 0x000000010dd386e3 __CFRunLoopRun + 867 16 核心基础 0x000000010dd380f8 CFRunLoopRunSpecific + 488 17 图形服务 0x00000001124b3ad2 GSEventRunModal + 161 18 UIKit 0x000000010e645f09 UIApplicationMain + 171 19 度 CL 0x000000010dc38412 主 + 114 20 libdyld.dylib 0x000000011068592d 开始 + 1 21 ??? 0x0000000000000001 0x0 + 1 ) libc++abi.dylib:以 NSException 类型的未捕获异常终止 (lldb)

【问题讨论】:

  • 设置断点并逐步检查哪一行导致崩溃。
  • Interface Builder 中的标签和文本字段是否连接?
  • 我认为您的标签、文本字段或按钮的插座连接错误,请再次检查
  • 我检查了插座连接正确。
  • 没有示例项目

标签: ios swift unrecognized-selector


【解决方案1】:

关键信息是

[DegreeCL.ViewController btnPressed:]: 无法识别的选择器发送到实例 ...'

这意味着在 Interface Builder 中某处与操作 btnPressed 存在死连接。删除它。

您可以使用 ⇧⌘F 搜索btnPressed。

【讨论】:

    【解决方案2】:

    SIGABRIT - 由于多种原因发送信号,但在这种情况下,我认为您的内存有问题。

    您应该使用po $arg1 选项打开All Exeptions,它将识别错误。

    【讨论】:

    • 如何打开它?
    • Go to BrakePoint Navigator (left side top Xcode) -> 底部你会看到 PLUS + -> Exeption BrakePoint -> Add Action -> po $arg1 -> Hit Enter
    【解决方案3】:

    从界面生成器中选择您的按钮,然后从utilities 中选择connection inspector 并检查是否应该有额外的连接操作方法,单击x 将其删除,您的问题将得到解决!

    根据您的崩溃日志,它应该是 btnPressed!

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2021-05-29
      • 1970-01-01
      • 1970-01-01
      • 2018-11-05
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多