I am working on an iOS app. I want it to support iOS 7 and 8. This happens pretty nicely, however there are many different parts of the application that use the Apple API. Some of these APIs work both in iOS 8 and 7. However, some of them are deprecated in iOS 8. So I went to the Apple developer site to see what to replace them (new methods / etc ....).
However, I now have a problem that the application will work on iOS 8 perfectly, but some of its parts do not work properly on iOS 7, since I'm trying to use the iOS 8 API ... (laughs).
So, I just wanted to know what the best way to implement code that works on iOS 8 and 7. I had a few ideas (below), but I'm not sure which is better:
IDEA 1
Whenever I have code that does not work on both OSs, I use the if function (which calls the macro) as follows:
if (SYSTEM_VERSION_LESS_THAN(@"8.0")) {
// iOS 7 device. Use iOS 7 apis.
}
else {
// iOS 8 (or higher) - use iOS 8 apis.
}
IDEA 2
I was thinking about using ifdef definitions around the application, for example:
#ifdef __IPHONE_8_0
#else
#endif
Which way is better? I would think that the second idea is much faster and uses less resources?
Or both of my garbage? Is there a better way to solve this problem?
Thanks for your time, Dan.
source
share