How do I check if a device is running iOS 6?
Solution 1
As Before comparing float parameters you should put 6.0 in a float variable so that LHS and RHS should be the same to compare:
float currentVersion = 6.0;
if ([[[UIDevice currentDevice] systemVersion] floatValue] >= currentVersion)
{
NSLog(@"Running in IOS-6");
}
Solution 2
NSString *versionString = [[UIDevice currentDevice] systemVersion]; // iOS version as string
int versionStringInt = [ver intValue]; // iOS version as int
float versionStringFloat = [ver floatValue]; // iOS version as float
Related videos on Youtube
hanumanDev
Updated on October 31, 2022Comments
-
hanumanDev over 1 year
Possible Duplicate:
How can we programmatically detect which iOS version is device running on?How do I check if a device is running iOS 6? I need to check to see if the os is iOS 6 in order to change my youtube video urls because of the release notes from Apple on how to handle them in iOS6
As of iOS 6, embedded YouTube URLs in the form of http://www.youtube.com/watch?v=oHg5SJYRHA0 will no longer work. These URLs are for viewing the video on the YouTube site, not for embedding in web pages. Instead, the format that should be used is described in https://developers.google.com/youtube/player_parameters.
I was thinking of an if else statement to handle this.
thanks for any help
-
James over 11 yearsLet me refer you to this question and answer...
-
-
Shayne over 11 yearsYou might want to do something like
if (deviceVersion >= 6.0)
because as soon as 6.1 rolls out , that code will fail and assume its on 5.x again. -
Roger over 11 yearsChecking for an explicit version number is almost always wrong. Check for capabilities instead.
-
Kamar Shad over 11 yearshey @Shayne you are right but here i just show that i am also not favor for above that's why ik am modifying my answer.
-
Yarek T over 11 years@Roger So how do you check for capabilities instead? For example Using the new
UIActivityViewController
in IOS6 for social sharing functions, and callingTWTweetComposeViewController
and email sharing manually when its not supported ? -
Abhinit over 10 years[[UIDevice currentDevice] systemVersion] is probably the most inefficient way of checking for iOS version numbers. Its not clear why, but this function takes precious CPU cycles to return a version number. Use NSFoundationVersionNumber instead. developer.apple.com/library/ios/documentation/cocoa/reference/…