IPhone : How to detect version of an iOS device

on Wednesday, February 25, 2015

Below is my code try to detect the version number of a device below 7.9. On my friend 's phone which have IOS 7.1.1 still going to the else-statement instead going to the if-statement.



NSString* minimumVersionString = @"7.9";
NSComparisonResult versionComparison = [[[UIDevice currentDevice] systemVersion] compare:minimumVersionString options:NSNumericSearch];

if (versionComparison == NSOrderedSame || versionComparison == NSOrderedAscending)
{

}
else {
[self popoverCategoryWithAlertController];
}


I would have thought if a device which has IOS 7.1.2 or lower will be executed this if-statement :



if (versionComparison == NSOrderedSame || versionComparison == NSOrderedAscending)


But it was not.. Am I use a wrong way to check the device IOS version


I even do this but same result:



if ([NSProcessInfo instanceMethodForSelector:@selector(isOperatingSystemAtLeastVersion:)]) {
if ([[NSProcessInfo processInfo] isOperatingSystemAtLeastVersion:versions])
[self popoverCategoryWithAlertController];
else {

}
}

0 comments:

Post a Comment