ios 設備信息獲取

1.導入string

#import <sys/utsname.h>it

//MARK: 獲取設備型號io

+ (NSString *)currentPhoneModel {import

    

    struct utsname systemInfo;object

    uname(&systemInfo);coding

    NSString *phoneModel = [NSString stringWithCString: systemInfo.machine encoding:NSASCIIStringEncoding];im

    if ([phoneModel isEqualToString:@"iPhone3,1"] ||di

        [phoneModel isEqualToString:@"iPhone3,2"])   return @"iPhone 4";vi

    if ([phoneModel isEqualToString:@"iPhone4,1"])   return @"iPhone 4S";encoding

    if ([phoneModel isEqualToString:@"iPhone5,1"] ||

        [phoneModel isEqualToString:@"iPhone5,2"])   return @"iPhone 5";

    if ([phoneModel isEqualToString:@"iPhone5,3"] ||

        [phoneModel isEqualToString:@"iPhone5,4"])   return @"iPhone 5C";

    if ([phoneModel isEqualToString:@"iPhone6,1"] ||

        [phoneModel isEqualToString:@"iPhone6,2"])   return @"iPhone 5S";

    if ([phoneModel isEqualToString:@"iPhone7,1"]) return @"iPhone 6 Plus";

    if ([phoneModel isEqualToString:@"iPhone7,2"]) return @"iPhone 6";

    if ([phoneModel isEqualToString:@"iPhone8,1"]) return @"iPhone 6s";

    if ([phoneModel isEqualToString:@"iPhone8,2"]) return @"iPhone 6s Plus";

    if ([phoneModel isEqualToString:@"iPhone8,4"]) return @"iPhone SE";

    if ([phoneModel isEqualToString:@"iPhone9,1"]) return @"iPhone 7";

    if ([phoneModel isEqualToString:@"iPhone9,2"]) return @"iPhone 7 Plus";

    if ([phoneModel isEqualToString:@"iPhone10,1"] ||

        [phoneModel isEqualToString:@"iPhone10,4"]) return @"iPhone 8";

    if ([phoneModel isEqualToString:@"iPhone10,2"] ||

        [phoneModel isEqualToString:@"iPhone10,5"]) return @"iPhone 8 Plus";

    if ([phoneModel isEqualToString:@"iPhone10,3"] ||

        [phoneModel isEqualToString:@"iPhone10,6"]) return @"iPhone X";

    if ([phoneModel isEqualToString:@"iPhone11,8"])   return @"iPhone XR";

    if ([phoneModel isEqualToString:@"iPhone11,2"])   return @"iPhone XS";

    if ([phoneModel isEqualToString:@"iPhone11,6"] ||

        [phoneModel isEqualToString:@"iPhone11,4"])   return @"iPhone XS Max";

    

    return @"Unknown";

}

2.

//獲取APP當前版本號

[[[NSBundle mainBundle] infoDictionary] objectForKey:@"CFBundleShortVersionString"];

3.

//獲取設備系統版本

[[UIDevice currentDevice] systemVersion];

相關文章
相關標籤/搜索