Created
January 29, 2017 07:13
-
-
Save koogawa/3236405d2172280c5a14fac2184a69cb to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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