【问题标题】:timer.invalidate() causes a crash,saying thread1:breakpoint1.1timer.invalidate() 导致崩溃,说线程 1:断点 1.1
【发布时间】:2015-08-11 09:43:12
【问题描述】:

导入 UIKit

class ViewController: UIViewController
 {


    @IBOutlet weak var secondsLabel: UILabel!
    @IBOutlet weak var milliSecondsLabel: UILabel!

    var milliTimer=NSTimer()

    var count:Int=1
    var milliCount:Int=1

    @IBAction func StartPauseTimer(sender: AnyObject)
    {
        milliTimer=NSTimer.scheduledTimerWithTimeInterval(1/100, target: self, selector: Selector("milliIncTimer"), userInfo: nil, repeats: true)

    }
    @IBAction func StopTimer(sender: AnyObject)
    {
        milliTimer.invalidate()
        count = 1  ///this the place i get the error 
                    //on pressing stop button,
                    //it says thread1:breakpoint1.1
        milliCount = 1

        secondsLabel.text = "0"
        milliSecondsLabel.text = " "
    }
    override func viewDidLoad()
    {
        super.viewDidLoad()

    }
    func milliIncTimer()
    {
        if milliCount==101
        {
            milliCount = 1
            secondsLabel.text = "\(count++)"
        }
        milliSecondsLabel.text = "\(milliCount++)"
    }

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


}

日志这样说

在 UIViewAlertForUnsatisfiableConstraints 创建一个符号断点,以便在调试器中捕获它。 中列出的 UIView 上的 UIConstraintBasedLayoutDebugging 类别中的方法也可能会有所帮助。 (lldb)

【问题讨论】:

    标签: ios xcode swift nstimer stopwatch


    【解决方案1】:

    你可能不小心放置了一个断点。

    在你的代码就行了:

    count = 1
    

    现在在那条线上向左看,你会看到一个蓝色箭头。

    您可以通过将此箭头向右拖动并松开来删除该箭头。

    希望这对您有所帮助!

    【讨论】:

      猜你喜欢
      • 2022-01-18
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2013-10-27
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多