Created
May 31, 2015 20:15
-
-
Save nielsbot/ba06510907886bae5ae7 to your computer and use it in GitHub Desktop.
simple Core Motion sample
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
import CoreMotion | |
public class Main | |
{ | |
var motionManager:CMMotionActivityManager! | |
let motionHandler:CMMotionActivityHandler! = { (activity:CMMotionActivity?) -> Void in | |
let desc = activity?.debugDescription ?? "no activity" | |
println("activity is \(desc)") | |
} | |
init?() | |
{ | |
if !CMMotionActivityManager.isActivityAvailable() { return nil } | |
self.motionManager = CMMotionActivityManager() | |
self.motionManager.startActivityUpdatesToQueue( NSOperationQueue.mainQueue(), withHandler: self.motionHandler ) | |
NSRunLoop.mainRunLoop().run() | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment