您好,欢迎来到化拓教育网。
搜索
您的当前位置:首页iOS版本号相关问题

iOS版本号相关问题

来源:化拓教育网

为了iOS10 的适配,可能需要区分版本问题

#if __IPHONE_OS_VERSION_MAX_ALLOWED >= 100000 

// iOS 10.0以后
#else 

#endif

获取当前的版本号

// 获取当前 info 的版本号
- (NSString*)loadAppVersion
{
    // 获取 info 字典
    NSDictionary* info = [NSBundle mainBundle].infoDictionary;
    
    // 获取当前程序的版本号
    NSString* appVersion = info[@"CFBundleShortVersionString"];
    return appVersion;
}

版本号比较问题
使用自带的NSString 类中的方法

// NSOrderedDescending是降序,如果oldVersion > newVersion用这个函数相比较那么就等于降序
NSString *oldVersion = @"2.1.0";    NSString *newVersion = @"2.3.0";    
if ([oldVersion compare:newVersion options:NSNumericSearch] ==NSOrderedDescending)   
{        
    NSLog(@"%@ is bigger",oldVersion);    
}
else    {        
    NSLog(@"%@ is bigger",newVersion);    
}

跳转到AppStore,评分或者更新

#if TARGET_IPHONE_SIMULATOR//模拟器
    
    NSLog(@"这是模拟器,无法打开appstore");
    
#elif TARGET_OS_IPHONE//真机
 // 贪吃蛇大作战 https://appsto.re/cn/RKGYcb.i    这种地址在appStore中很难打开
    
// 支付宝地址: NSString *str = [NSString 
    NSLog(@"这是真机");
    [[UIApplication sharedApplication]openURL:[NSURL 
#endif

Copyright © 2019- huatuo9.cn 版权所有 赣ICP备2023008801号-1

违法及侵权请联系:TEL:199 1889 7713 E-MAIL:2724546146@qq.com

本站由北京市万商天勤律师事务所王兴未律师提供法律服务