I understand that UIAccelerometerDelegate is now deprecated as of ios5.
I still need to submit the app so that people with ios3.2 (iPad’s first version) can still use it. The app is just for iPad, but I noticed that the core motion library is for ios4 and higher… Does this mean I can’t submit with the deprecated UIAccelerometerDelegate? Will the UIAccelerometerDelegate cease to work in newer iOS?
Can I use both, so people with ios3.2 can still have acceleration and how would I implement this?
Thanks to any whom can help me!
It’ll likely stop working at some point, but Apple don’t reject apps just for using deprecated APIs.
You can select which API to use at runtime, though it’s a bit more complicated than usual because CoreMotion relies on blocks, which are new to iOS 4. Since blocks are object literals (ie, their creation happens naturally as part of program flow rather than explicitly at your command) you need to signal that you don’t mind if they don’t exist to the linker, for which you can add
-weak-lSystemto your command line.Following that you can use a standard runtime switch, like:
NSClassFromStringasks the runtime to return theClassfor the named class. It returns either that ornilif the named class doesn’t exist in the runtime. It can therefore be used to see whether specific classes are implemented, a much better solution than relying on coding outside knowledge about library version numbers, etc.