【发布时间】:2012-12-31 05:57:53
【问题描述】:
需要检查预处理器宏中的条件。
#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_GREATER_THAN_OR_EQUAL_TO(@"6.0"))
{
#import <Social/SLServiceTypes.h>
#import <Social/SLRequest.h>
#import <Social/Social.h>
#import <Social/SocialDefines.h>
}
【问题讨论】:
-
另外,不要测试 iOS 版本/设备类型,不要猜测,检查功能。