Obtaining the system version in IOS is relatively simple ([[UIDevicecurrentDevice] systemVersion]);
[[[UIDevice currentDevice] systemVersion] floatValue] is used to convert system strings to float on the network.
However, I encountered a problem in this method, that is, if the system version is 7.1.1, there is a problem with the float generated by the conversion, and the data generated by debug is 7.0899999999999. Cause a problem,
Later, I wrote a method to solve this problem.
+ (CGFloat) systemVersion {
NSString * sVersion = [[UIDevice currentDevice] systemVersion];
Nsange fRange = [sVersion rangeOfString: @ "."];
CGFloat version = 0.0f;
If (fRange. location! = NSNotFound ){
SVersion = [sVersion stringByReplacingOccurrencesOfString: @ "." withString: @ ""];
NSMutableString * mVersion = [NSMutableString stringWithString: sVersion];
[MVersion insertString: @ "." atIndex: fRange. location];
Version = [mVersion floatValue];
} Else {
// The version should be faulty (because the ios version is 7.0.1, no decimal point is found)
Version = [sVersion floatValue];
}
Return version;
}