Mayur Tolani
Mayur Tolani

Reputation: 1487

timer.invalidate() causes a crash,saying thread1:breakpoint1.1

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


}

the logs say this

Make a symbolic breakpoint at UIViewAlertForUnsatisfiableConstraints to catch this in the debugger. The methods in the UIConstraintBasedLayoutDebugging category on UIView listed in may also be helpful. (lldb)

Upvotes: 0

Views: 341

Answers (1)

Entitize
Entitize

Reputation: 4969

You may have placed a breakpoint accidently.

In your code on the line:

count = 1

Now on that line look left and you will see a blue arrow.

You can delete the arrow by dragging this arrow to the right and let go.

Hope this helped you!

Upvotes: 1

Related Questions