Rya*_*yan 10 xcode itunes objective-c ios
该identifierForVendor要求iOS6的,所以如果我的应用程序目前支持iOS4的,所以我不能使用它,因为我的更新应该总能满足我的应用程序以前分钟.需求?
Nak*_*aka 28
你可以用这个:
NSString *udid;
if (SYSTEM_VERSION_GREATER_THAN_OR_EQUAL_TO(@"6.0"))
udid = [UIDevice currentDevice].identifierForVendor.UUIDString;
else
udid = [UIDevice currentDevice].uniqueIdentifier;
Run Code Online (Sandbox Code Playgroud)
使用预处理器代码:
#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)
Run Code Online (Sandbox Code Playgroud)
您不需要预处理器宏,您应该检查它是否响应,如下所示:
if ([[UIDevice currentDevice]respondsToSelector:@selector(identifierForVendor)]) {
return [UIDevice currentDevice].identifierForVendor.UUIDString;
}else{
// return [UIDevice currentDevice]. uniqueIdentifier
return [[UIDevice currentDevice] performSelector:@selector(uniqueIdentifier)];
}
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
18907 次 |
| 最近记录: |