Should I handle obsolescence when I support a lower version of iOS?

For example, let's say my iOS application supports up to iOS 7.0, and I want to make a warning. In iOS 7, I would use UIAlertView . In iOS 8/9, this is rejected by the UIAlertController . Do I need to check if currentVersion > iOS7 and then create BOTH alerts, alertView for iOS7 and alertController for iOS8 +? Or can I use UIAlertView in an iOS7 application, although it will ultimately work on iOS9 + devices?

I will need to check what the current version of iOS is and implement several objects (one for each version) in simple questions like ?

+5
source share
1 answer

Deferral is just a note that the function may be removed in a future version. However, an obsolete class or method still works.

So, you can just continue to use UIAlertView and face the risk of hacking in a future version of iOS. It still works on iOS 9. There is no guarantee that it will continue to work with iOS 10.

The best solution here is to check if the UIAlertController is available at runtime . If so, use this class for your warning, otherwise return to UIAlertView .

Usually you do not check the version of iOS! It’s better to check if a method or class is available, except in very rare cases when Apple explicitly tells you to check the version of iOS: this happens when a method that was considered private was published by Apple.

+1
source

Source: https://habr.com/ru/post/1245090/


All Articles