ios 判断系统版本,及Interger打印格式

来源:互联网 发布:淘宝如何代理虚拟 编辑:程序博客网 时间:2024/06/05 08:48

refs:

http://stackoverflow.com/questions/23818606/semantic-issue-implicit-declaration-of-function

http://stackoverflow.com/questions/4405006/nslog-printf-specifier-for-nsinteger


1)ios 判断系统版本,分别处理

Add these lines from your link to your .pch file. Clean and build. It should go away.

#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)

使用

 if (SYSTEM_VERSION_GREATER_THAN_OR_EQUAL_TO(@"7.0") && SYSTEM_VERSION_LESS_THAN(@"7.1")) {       xxxx;    }


2)Interger NSLog打印报警,之前项目是32位,后来升级为64位导致的。

 NSLog(@"%d", i);
改位

 NSLog(@"%ld", i);

With current Xcode, you can make use of the z and t modifiers to handleNSInteger andNSUInteger without warnings, on all architectures.

You want to use %zd for signed, %tu for unsigned, and%tx for hex.


0 0
原创粉丝点击