判斷 iOS 版本

weixin_34402408發表於2015-11-30
  • Before iOS 8
if(NSFoundationVersionNumber > NSFoundationVersionNumber_iOS_7_1)
{
    // > iOS 7.1
}

// or 
UIDevice *device = [UIDevice currentDevice];

if([device.systemVersion compare:@"7.0" options:NSNumericSearch] == NSOrderedAscending)
{
    // >= 7.0
}
  • After
NSOperatingSystemVersion version = {.majorVersion=8,.minorVersion=0,.patchVersion=0};

if([[NSProcessInfo processInfo]isOperatingSystemAtLeastVersion:version])
{
    // >= 8.0.0
}

相關文章