星空网 > 软件开发 > 操作系统

iOS版本比较方法

之前一直把版本号转换为floatValue,但是最近在项目中又出现了float的问题,主要是

NSString表示为@"17.30",转换为floatValue 值为17.299999,然后做了一些放大处理,导致不精确,就是精度少了1

所以都不敢在系统版本比较的过程中把值强制转换为floatValue了。

/* * System Versioning Preprocessor Macros hovertree.com */#define SYSTEM_VERSION_EQUAL_TO(v)([[[UIDevice currentDevice] systemVersion] compare:v options:NSNumericSearch]==NSOrderedSame)#define SYSTEM_VERSION_GREATER_THAN(v)([[[UIDevice currentDevice] systemVersion] compare:v options:NSNumericSearch]==NSOrderedDescending)#define SYSTEM_VERSION_GREATER_THAN_OR_EQUAL_TO(v)([[[UIDevice currentDevice] systemVersion] compare:v options:NSNumericSearch]!=NSOrderedAscending)#define SYSTEM_VERSION_LESS_THAN(v)([[[UIDevice currentDevice] systemVersion] compare:v options:NSNumericSearch]==NSOrderedAscending)#define SYSTEM_VERSION_LESS_THAN_OR_EQUAL_TO(v)([[[UIDevice currentDevice] systemVersion] compare:v options:NSNumericSearch]!=NSOrderedDescending)/* * Usage 何问起 */if(SYSTEM_VERSION_LESS_THAN(@"4.0")){...}if(SYSTEM_VERSION_GREATER_THAN_OR_EQUAL_TO(@"3.1.1")){...}
推荐:http://www.cnblogs.com/roucheng/p/3528371.html



原标题:iOS版本比较方法

关键词:IOS

IOS
*特别声明:以上内容来自于网络收集,著作权属原作者所有,如有侵权,请联系我们: admin#shaoqun.com (#换成@)。

东南亚海运爆仓:https://www.goluckyvip.com/tag/99288.html
Joom佣金:https://www.goluckyvip.com/tag/9929.html
东南亚海运航线图:https://www.goluckyvip.com/tag/99290.html
到东南亚海运运费:https://www.goluckyvip.com/tag/99291.html
东南亚海运费用:https://www.goluckyvip.com/tag/99292.html
到东南亚的海运价格表:https://www.goluckyvip.com/tag/99293.html
在古巴做游轮 古巴旅游项目:https://www.vstour.cn/a/363194.html
西藏旅游攻略自驾游需要多少天 去西藏旅游自驾游要多久时间:https://www.vstour.cn/a/363195.html
相关文章
我的浏览记录
最新相关资讯
海外公司注册 | 跨境电商服务平台 | 深圳旅行社 | 东南亚物流