Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to detect current iOS is 4.1 or 4.2? [duplicate]

Tags:

iphone

ios4

Possible Duplicate:
Check iPhone iOS Version

I tried with this code:

#if (__IPHONE_OS_VERSION_MAX_ALLOWED >= __IPHONE_2_2)
    NSLog(@"iPhone 4.2");
#endif

but when I run it again on simulator 4.1, I still get the log "iPhone 4.2" in console.

Thanks for helping me.

Tung Do

like image 944
Tùng Đỗ Avatar asked Nov 18 '10 07:11

Tùng Đỗ


2 Answers

You should probably avoid asking about the system version altogether.

A better design would ask about a specific feature.

For instance: if (NSClassFromString(@"UIPrintInfo")) would tell you if the current device supports the printing API,available in 4.2 or higher.

That way you can plan your code to use a feature if it's available, on not based on the OS version.

like image 105
Moshe Gottlieb Avatar answered Oct 09 '22 08:10

Moshe Gottlieb


float version = [[[UIDevice currentDevice] systemVersion] floatValue]; 
like image 40
Bourne Avatar answered Oct 09 '22 08:10

Bourne