Swift 3 - 线程1:信号SIGABRT无法识别的选择器发送到实例

时间:2017-02-23 01:18:57

标签: swift xcode

有什么可以帮我解决这个问题吗?我一直试图解决这个问题几个小时,但到目前为止还没有任何工作。每次我点击一个按钮,它立即导致错误线程1:信号SIGABRT。

这是代码(注意:它仍在进行中):

import UIKit
class ViewController: UIViewController {
@IBOutlet var Sec1: UILabel!
@IBOutlet var Sec2: UILabel!
@IBOutlet var Sec3: UILabel!
@IBOutlet var Sec4: UILabel!
@IBOutlet var Sec5: UILabel!
@IBOutlet var Sec6: UILabel!
@IBOutlet var Sec7: UILabel!
@IBOutlet var Sec8: UILabel!
@IBOutlet var Sec9: 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.
}
var x = 2
   // if (x%2 == 0) {
    @IBAction func ButtonPressed(Button1: UIButton) {
   Sec1.text = "X"
    }    
}

这是错误:

**2017-02-23 07:58:14.194 Tic Tac Toe IS[46707:2457511] -[Tic_Tac_Toe_IS.ViewController ButtonPressed:]: unrecognized selector sent to instance 0x7fb8a8d04ee0
2017-02-23 07:58:14.202 Tic Tac Toe IS[46707:2457511] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[Tic_Tac_Toe_IS.ViewController ButtonPressed:]: unrecognized selector sent to instance 0x7fb8a8d04ee0'
*** First throw call stack:
(
    0   CoreFoundation                      0x000000010bebfd4b __exceptionPreprocess + 171
    1   libobjc.A.dylib                     0x00000001092be21e objc_exception_throw + 48
    2   CoreFoundation                      0x000000010bf2ff04 -[NSObject(NSObject) doesNotRecognizeSelector:] + 132
    3   CoreFoundation                      0x000000010be45005 ___forwarding___ + 1013
    4   CoreFoundation                      0x000000010be44b88 _CF_forwarding_prep_0 + 120
    5   UIKit                               0x000000010978f8bc -[UIApplication sendAction:to:from:forEvent:] + 83
    6   UIKit                               0x0000000109915c38 -[UIControl sendAction:to:forEvent:] + 67
    7   UIKit                               0x0000000109915f51 -[UIControl _sendActionsForEvents:withEvent:] + 444
    8   UIKit                               0x0000000109914e4d -[UIControl touchesEnded:withEvent:] + 668
    9   UIKit                               0x00000001097fd545 -[UIWindow _sendTouchesForEvent:] + 2747
    10  UIKit                               0x00000001097fec33 -[UIWindow sendEvent:] + 4011
    11  UIKit                               0x00000001097ab9ab -[UIApplication sendEvent:] + 371
    12  UIKit                               0x0000000109f9872d __dispatchPreprocessedEventFromEventQueue + 3248
    13  UIKit                               0x0000000109f91463 __handleEventQueue + 4879
    14  CoreFoundation                      0x000000010be64761 __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION__ + 17
    15  CoreFoundation                      0x000000010be4998c __CFRunLoopDoSources0 + 556
    16  CoreFoundation                      0x000000010be48e76 __CFRunLoopRun + 918
    17  CoreFoundation                      0x000000010be48884 CFRunLoopRunSpecific + 420
    18  GraphicsServices                    0x000000010ddf9a6f GSEventRunModal + 161
    19  UIKit                               0x000000010978dc68 UIApplicationMain + 159
    20  Tic Tac Toe IS                      0x0000000108cdb7af main + 111
    21  libdyld.dylib                       0x000000010ce6f68d start + 1
)
libc++abi.dylib: terminating with uncaught exception of type NSException
(lldb)** 

1 个答案:

答案 0 :(得分:0)

你能检查你的@IBAction功能ButtonPressed()与故事板之间的联系吗?您可以从"连接检查器"中检查它。在故事板上。