如何确定和比较(>,<等等)运行该应用程序的iPhone的当前操作系统版本?3.0中有一个错误,但3.1+中没有,所以如果当前操作系统版本不是> = 3.1,我希望能够跳过一些代码.
这需要在运行时而不是编译时!
Mez*_*Mez 22
例如,您可以执行以下操作:
NSString *reqSysVer = @"3.1";
NSString *currSysVer = [[UIDevice currentDevice] systemVersion];
if ([currSysVer compare:reqSysVer options:NSNumericSearch] != NSOrderedAscending)
{
//Do some clever stuff
}
Run Code Online (Sandbox Code Playgroud)
Ben*_*ieb 13
你的意思是确定操作系统的版本?SDK在构建时修复,但操作系统可能会更改.要获取操作系统版本,请使用[UIDevice currentDevice].systemVersion.要获得SDK版本,我认为您可以使用__IPHONE_OS_VERSION_MIN_REQUIRED.