无法比较 iOS 10 中的系统版本

Can not compare systemVersion in iOS 10

#define kIOS8_OR_LATER \
([[[UIDevice currentDevice] systemVersion] compare:@"8.0"] != NSOrderedAscending)

为什么 iOS 8.0 和 10 之间的比较不起作用?

if (kIOS8_OR_LATER) {
    NSLog(@"1");
} else {
    NSLog(@"0");
}

设备:

Xcode:

控制台保持记录 0,但在 iOS 9.

中工作正常

正常的字符串比较一次看一个字符。 1 排在 8 之前。所以你需要做比较数字:

#define kIOS8_OR_LATER \
    ([[[UIDevice currentDevice] systemVersion] compare:@"8.0" options:NSNumericSearch] != NSOrderedAscending)

那么比较就是810.