0

Noob IOS Dev can't figure out the error please, please some help thread1: EXC_BREAKPOINT (code=1,subcode=0x1003591fc) Ive tried everything I could and nothing (well everything I understood from other codes)

var pedometer :CMPedometer!
var stepCount :Int = 0
@IBOutlet var labelSteps: UILabel!
@IBAction func btnStart(_ sender: Any) {
    *Pedometer*
    if CMPedometer.isStepCountingAvailable() {
        self.pedometer.startUpdates(from: NSDate() as Date, withHandler: {
            data, error in
            if data != nil {
                // Add to existing counts
                self.stepCount += (data?.numberOfSteps as! Int)
                self.labelSteps.text = "\(self.stepCount)"

            }
        })
    }
}

@IBAction func btnStop(_ sender: Any) {
    //self.labelSteps.text = "0"
    //self.pedometer.stopUpdates()
    print("Stop")
}

Thanks. Hoping for a response soon.

James Zaghini
  • 3,895
  • 4
  • 45
  • 61
siege007
  • 3
  • 1

1 Answers1

0

Pedometer may not have been initialised? Try: var pedometer = CMPedometer()

Perhaps you haven't hooked up your labelSteps IBOutlet to the label in your storyboard/nib.

Could be one of those issues or both

James Zaghini
  • 3,895
  • 4
  • 45
  • 61