I assume it will just crash, right? If I develop an iPhone app that uses the iOS 4 SDKs and it makes it's way on into the app store, how can I ensure it doesn't get downloaded by a person running an older version of the iO开发者_StackOverflow中文版S?
Thanks in advance for your help!
If your project specifies 4.0 as the target then it won't even get loaded on the 3.2 phone - no problem.
When you publish an app to the store you specify the minimum OS level and acceptable devices (so you don't go looking for GPS on an iPod Touch, for example). There is a compatibility check that should prevent an app being loaded if it is not compatible. The App approval process (hopefully) makes sure that what you have said is compatible actually is.
If you somehow use APIs that don't exist on the device (because you are targeting a version prior to the introduction of that API or for any other reason) then yep, you'll get a crash due to unknown selector.
You can use
#if __IPHONE_OS_VERSION_MIN_REQUIRED >= 30200
to check what version you are targeting... the first number (3) is the major revision, the third number (2) is the minor revision. Hence the check shown is for 3.2.
Rather than using Adam Eberbach's approach using compile time preprocessor directives to split your code, consider using run time checks like respondsToSelector:
, using NSClassFromString
checks against nil to determine if classes exist, and weak-linking to new frameworks and libraries.
This will allow you to write one app that can live on multiple devices without any code segregation or separate binaries.
精彩评论