FAQ Database Discussion Community


iOS9 error on activityManager.startActivityUpdatesToQueue

ios,swift,core-motion,ios9
I opened my app in the new Xcode7 beta which worked perfectly fine in older version. Now I'm receiving errors, and i don't know how to solve it. Here is the code. Error is commented out. import UIKit import CoreMotion class ViewController: UIViewController { let activityManager = CMMotionActivityManager() let pedoMeter...

Decreasing accelerometer's sensitivity

ios,swift,sprite-kit,accelerometer,core-motion
I am making a game which have a square that moves from left to right, and at first I was using applyForce to do so, but I didn't like the results because it was not sensitive enough. Then I changed to velocity: func motionSensorUpdate(currentTime: CFTimeInterval){ let square = childNodeWithName(ksquarename) as!...

Unknown Type Name 'CMStepCounter'

objective-c,import,core-motion,health-kit
I'm trying to count the steps of user using CoreMotion, HealthKitand everything that is needed. At first I tried it with Swift (I'm not good with swift) and imported these two files: import HealthKit import CoreMotion And when I declared CMStepCounter it successfully declared it, means the type was found....

CoreMotion Basic

ios,xcode,swift,core-motion
import UIKit import CoreMotion class ViewController: UIViewController { @IBOutlet weak var label: UILabel! override func viewDidLoad() { super.viewDidLoad() let manager = CMMotionManager() if manager.accelerometerAvailable { println("accelerometerAvailable = true") manager.accelerometerUpdateInterval = 0.01 manager.startAccelerometerUpdatesToQueue(NSOperationQueue.mainQueue()) { [weak self] (data: CMAccelerometerData!, error: NSError!) in println("inside") println(data) println("x: \(data.acceleration.x)") println("y:...

startAccelerometerUpdatesToQueue Type of expression is ambiguous without more context

swift,core-motion,swift2
I am trying to translate the following code to Swift 2. manager.startAccelerometerUpdatesToQueue(NSOperationQueue.mainQueue()) { [weak self] (data: CMAccelerometerData!, error: NSError!) in self!.outputAccData(data.acceleration) } But this gives me the following error. Type of expression is ambiguous without more context Does anyone know why this is happening?...

Is it possible to obtain gyroscope data updates when app is in the background

ios,core-motion
My app uses a Bluetooth accessories so I turn the corresponding background mode on. Is it possible to receiving CoreMotion gyroscope data continuously in the background? The scenario is to scan and hook up a BLE peripheral device when the app is in the background. And to detect phone rotation...

How to get Acceleration Time & Acceleration Magnitude in iPhone

ios,iphone,core-motion,motion,uiaccelerometer
Currently I'm trying to use CMAcceleration to get accelerometer values for x,y& z axis is it possible to get Acceleration Time & Acceleration Magnitude with this x,y & z values.When i checked the developer forum i can't find any delegates / methods to get this two.Guide me to find the...

Rotation on Y axis in degree or radians in iOS

ios,rotation,accelerometer,gyroscope,core-motion
I need to get Rotation for iDevice on portrait mode, around Y axis of accelerometer, as per shown in this image, (reference: https://developer.apple.com/library/ios/documentation/EventHandling/Conceptual/EventHandlingiPhoneOS/motion_event_basics/motion_event_basics.html) How can i get rotation performed around Y axis, either in positive or negative. I've implemented few codes from stackoverflow/Apple code, i get no difference in roll,...

How do you save data that is being produced in a handler?

ios,swift,accelerometer,core-motion
The handler code (in this case, collecting accelerometer data) is being executed asynchronously when my accelerometer moves. That means if I try to save data.x, data.y, data.z in a variable, even if the variable is declared outside of the handler, the variable will be nil if I attempt to print...

Fetch/Refresh Health Kit Data Programmatically?

ios8,apple-watch,core-motion,health-kit
When you open the Health app, it updates it's values from somewhere, but if you don't actually open the app, the Healthkit only seems to update randomly (and very scarsely). For example, Step data objects don't get pulled from (wherever the iOS source comes from) or the Apple Watch until...

CMPedometer as property, Error code 103

objective-c,core-motion
I'm building a step manager class, and in my .m file, I've added CMPedometer as a property: @interface WDStepTrackerManager () @property (nonatomic, strong) CMPedometer *pedometer; @end I then instantiate it in my init method (I've also tried lazy instantiation -- no effect): - (instancetype)init { self = [super init]; if...

Apple watch standup detection

ios,watchkit,core-motion
I am now working on a app dealing with user's motion on the Apple watch. As shown on the Apple Watch, it recognize when you are sitting or standing. Is there any way to get access to it using API? Thanks