Since the launch of IOS 5, I have had to make some changes to my app that only apply when IOS 5 is being used. How can I tell when launching my app whther the user is using IOS 5 or IOS 4 or earlier?
Asked
Active
Viewed 365 times
3 Answers
1
if([[[UIDevice currentDevice] systemVersion] compare:@"5.0" options:NSNumericSearch] != NSOrderedDescending)
{
// code here
}
else
{
// code here
}

Ishu
- 12,797
- 5
- 35
- 51
1
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. More on this here - How to check iOS version?
But if you must then -
float version = [[[UIDevice currentDevice] systemVersion] floatValue];

Community
- 1
- 1

Srikar Appalaraju
- 71,928
- 54
- 216
- 264
0
Sometime is nice to know which version of iOS is used. But it is better to ask the system if a method exist:
// iOS 5 UINavigationBar backgroundImage
if ([self.navigationBar respondsToSelector:@selector(setBackgroundImage:forBarMetrics:)]) {
UIImage *backgroundImage = [UIImage imageNamed:@"titlebar.png"];
[self.navigationBar setBackgroundImage:backgroundImage forBarMetrics:UIBarMetricsDefault];
}

rckoenes
- 69,092
- 8
- 134
- 166