Skip to content

Instantly share code, notes, and snippets.

@koogawa
Created January 29, 2017 07:13
Show Gist options
  • Save koogawa/3236405d2172280c5a14fac2184a69cb to your computer and use it in GitHub Desktop.
Save koogawa/3236405d2172280c5a14fac2184a69cb to your computer and use it in GitHub Desktop.
if CMPedometer.isStepCountingAvailable() {
self.pedometer.startUpdates(from: NSDate() as Date) {
(data: CMPedometerData?, error) -> Void in
// アクティビティが変化するたびに呼ばれる
DispatchQueue.main.async(execute: { () -> Void in
if (error == nil) {
let steps = data!.numberOfSteps
self.stepLabel.text = "steps: \(steps)"
}
})
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment