Swift 在制作倒计时器时发出 SIGABRT 错误信号?

Swift Signal SIGABRT error while making countdown timer?

我正在为我的应用开发倒数计时器,它从 15 开始倒计时。这是我的代码:

//


import UIKit

class ViewController2: UIViewController {
     @IBOutlet weak var Timer: UILabel!


    var countd = 15








//
//
    override func viewDidLoad() {

    super.viewDidLoad()
    let time = NSTimer(timeInterval: 1.0, target: self,  selector: "updateCounter", userInfo: nil, repeats: true)
     Timer.text = String(countd)
NSRunLoop.mainRunLoop().addTimer(time, forMode: NSDefaultRunLoopMode)

    }

  func updateCounter(timer: NSTimer) {


        Timer.text = String(countd)

        if (countd > 0){

            Timer.text = String(countd--)
            Timer.text = String(countd)
        }

    }





        // Do any additional setup after loading the view.


    override func didReceiveMemoryWarning() {
        super.didReceiveMemoryWarning()
        // Dispose of any resources that can be recreated.
    }


    /*
    // MARK: - Navigation

    // In a storyboard-based application, you will often want to do a little preparation before navigation
    override func prepareForSegue(segue: UIStoryboardSegue, sender: AnyObject?) {
        // Get the new view controller using segue.destinationViewController.
        // Pass the selected object to the new view controller.
    }
    */

}

但是,当我 运行 它时,只要我到达带有计时器的部分,我就会看到标签闪烁 15 秒,但随后它立即因 SIGABRT 错误而崩溃。我能做什么?

改变

selector: "updateCounter"

selector: "updateCounter:"

请注意,在Swift 2.2中将很难犯这个错误(编译器会警告),而在Swift 3中将变得不可能(字符串文字选择器语法将变得非法).如果您不理解字符串文字选择器语法,您可能想更新到 Swift 2.2 now