Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to detect iPhone OS version in the app?

I would like to detect iPhone OS version in the app, can you post sample code as well. I tried using macro that didn't help.

like image 785
sid Avatar asked Dec 05 '09 23:12

sid


1 Answers

You need to use the macros if you want conditional compilation:

 #if __IPHONE_8_0
 // Works on >= version 8.0
 #else
 // Works on < version 8.0
 #endif

Or alternatively, to check at runtime, use:

float ver = [[[UIDevice currentDevice] systemVersion] floatValue];
if (ver >= 8.0) {
    // Only executes on version 8 or above.
}
like image 196
John Feminella Avatar answered Oct 08 '22 01:10

John Feminella