float version = [[[UIDevice currentDevice] systemVersion] floatValue];Please note how three part version number gets converted to float:
if (version > 4.0)
{
// iOS 4.2 specific code
}
else
{
// iOS 4.0.2 specific code
}
NSString *s = [[UIDevice currentDevice] systemVersion];I'm not really happy with the solution, but it works. Can live with that.
float version = [[[UIDevice currentDevice] systemVersion] floatValue];
NSLog(@"Version: %@ and %f", s, version);
NSLog(@"Version: %@ and %f", @"3.1.3", [@"3.1.3" floatValue]);
Version: 4.0.2 and 4.000000
Version: 3.1.3 and 3.100000
Update:
Always run code in real device! My development device iPhone4 with iOS 4.1 returns "4.1" as string, but that gives 4.0999999 as float value !!!