2016-09-22 12 views
0

スレッド:1 Signal SIGAGBRTがこのコード内にあるのはなぜですか?私はエラーを修正するために何を変更するのか分からない。アプリケーションが起動し、ボタンを押すとアプリケーションはキャンセルしてエラーを表示します。スレッド: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:]: unrecognized selector sent to instance 0x7fa7bb643d40 
2016-09-22 14:15:51.674 DegreeCL[19045:1774964] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[DegreeCL.ViewController btnPressed:]: unrecognized selector sent to instance 0x7fa7bb643d40' 
*** First throw call stack: 
(
    0 CoreFoundation      0x000000010de1dd85 __exceptionPreprocess + 165 
    1 libobjc.A.dylib      0x000000010fbc1deb objc_exception_throw + 48 
    2 CoreFoundation      0x000000010de26d3d -[NSObject(NSObject) doesNotRecognizeSelector:] + 205 
    3 CoreFoundation      0x000000010dd6ccfa ___forwarding___ + 970 
    4 CoreFoundation      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 sendEvent:] + 865 
    11 UIKit        0x000000010e666dc6 -[UIApplication sendEvent:] + 263 
    12 UIKit        0x000000010e640553 _UIApplicationHandleEventQueue + 6660 
    13 CoreFoundation      0x000000010dd43301 __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION__ + 17 
    14 CoreFoundation      0x000000010dd3922c __CFRunLoopDoSources0 + 556 
    15 CoreFoundation      0x000000010dd386e3 __CFRunLoopRun + 867 
    16 CoreFoundation      0x000000010dd380f8 CFRunLoopRunSpecific + 488 
    17 GraphicsServices     0x00000001124b3ad2 GSEventRunModal + 161 
    18 UIKit        0x000000010e645f09 UIApplicationMain + 171 
    19 DegreeCL       0x000000010dc38412 main + 114 
    20 libdyld.dylib      0x000000011068592d start + 1 
    21 ???         0x0000000000000001 0x0 + 1 
) 
libc++abi.dylib: terminating with uncaught exception of type NSException 
(lldb) 
+0

ブレークポイントを設定し、どの行がクラッシュするかを段階的にチェックします。 –

+0

ラベルとテキストフィールドはInterface Builderに接続されていますか? – vadian

+0

ラベル、テキストフィールド、またはボタンのいずれかにコンセントを間違って接続したと思う、もう一度確認してください – Tj3n

答えて

1

重要な情報がある

[DegreeCL.ViewController btnPressed:]:認識されていないセレクタはインスタンスに送信...」Interface Builderで意味

がどこかに死ん接続がありますアクションbtnPressed。それを除く。

btnPressed⇧⌘Fで検索できます。

1

をクリックして削除し、utilitiesからconnection inspectorを選択し、余分な接続アクションメソッドを持っている場合があるべきであることを確認した後、インターフェースビルダから、あなたのボタンを選択しますxあなたの問題は解決されます!

クラッシュログごとにbtnPressedである必要があります!

1

SIGABRIT - 多くの理由でシグナルが送信されますが、この場合はメモリに問題があると思います。

po $arg1のオプションを使用してAll Exeptionsをオンにする必要があります。エラーが特定されます。

+0

どうすればいいですか? –

+0

BrakePoint Navigator(左上のXcode) - >下にPLUS +が表示されます - Exeption BrakePoint - >アクションの追加 - > po $ arg1 - > Enter – C0mrade

関連する問題