How to get the proper iOS version programmatically?
Solution 1
In iOS 8 and above, you can use:
[[NSProcessInfo processInfo] operatingSystemVersion]
If you want to check the availablity of particular API, then there is a better way than checking OS versions, as explained here.
Solution 2
you can get it with this, in NSString format:
[UIDevice currentDevice].systemVersion
NEW EDIT
PS
you changed your question... now my answer has no more sense... next time add new lines with an evident edit, to let everyone understand the thread of the question/answers, please
Solution 3
Objective C
// define macro
#define SYSTEM_VERSION_GREATER_THAN_OR_EQUAL_TO(v) ([[[UIDevice currentDevice] systemVersion] compare:v options:NSNumericSearch] != NSOrderedAscending)
#define SYSTEM_VERSION_LESS_THAN(v) ([[[UIDevice currentDevice] systemVersion] compare:v options:NSNumericSearch] == NSOrderedAscending)
then use like that:
if (SYSTEM_VERSION_LESS_THAN(@"10.0")){
//your code here
}
Solution 4
NSString *osVersion = [[UIDevice currentDevice] systemVersion];
Splendor_iOS
Updated on June 17, 2022Comments
-
Splendor_iOS almost 2 years
I want to get the current os version of user device for some analysis in backend. Im trying to get it as below,
[[[UIDevice currentDevice] systemVersion] floatValue]; **//not returning the minor version number**
When I test this by running in my iPhone which is having iOS 8.0.2, this api returns me 8.000000 as the result but I need the exact iOS version which is 8.0.2
Any help in fixing this problem is appreciated in advance.