Question

I want to create a customized UIView class (a static lib) for some app developers. I have created CMMotionManager instance in my code. I've found that if an app developer also creates the CMMotionManager instance in his code, one of our CMMotionManager instance will fail to handle the gyro/accelerometer values. I realize that the UIWebview can get these values (e.g. javascript code: window.ondevicemotion = function(e) {...}) while the app is getting them, I think there might be a way to avoid this conflict. Any ideas about how to avoid this conflict?

Was it helpful?

Solution

As with the CLLocation manager you should only implement one instance of CMMotionManager per app, I would recommend creating a singleton class and accessing your CMMotionManager from there, see this post

CMMotionManager is a global resource? What does this means?

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top