Triton Man Triton Man - 1 year ago 56
iOS Question

UIAlertController if iOS 8, otherwise UIAlertView

I want to conform to the UIAlertController used in iOS 8 since UIAlertView is now deprecated. Is there a way that I can use this without breaking support for iOS 7? Is there some kind of if condition I can do to check for iOS 8 otherwise do something else for iOS 7 support?

Answer Source

Please see the answer of Erwan (below my answer) as I see it is the best.


You can check the iOS version to use appropriate control like this:

if (([[[UIDevice currentDevice] systemVersion] compare:@"8.0" options:NSNumericSearch] == NSOrderedAscending)) {
    // use UIAlertView
else {
    // use UIAlertController