获取设备信息、APP信息、型号信息代码

-(NSString*)getAPPInfo

{

    NSDictionary *infoDictionary = [[NSBundle mainBundle] infoDictionary];

//    NSLog(@"app_Name:%@",[infoDictionary objectForKey:@"CFBundleDisplayName"]);

//    NSLog(@"app_Version:%@",[infoDictionary objectForKey:@"CFBundleShortVersionString"]);

//    NSLog(@"app_build:%@",[infoDictionary objectForKey:@"CFBundleVersion"]);

    

    NSString *appString = [NSStringstringWithFormat:@"\napp_Name:%@\napp_Version:%@\napp_build:%@",[infoDictionary objectForKey:@"CFBundleDisplayName"],[infoDictionary objectForKey:@"CFBundleShortVersionString"],[infoDictionary objectForKey:@"CFBundleVersion"]];

    

    return appString;

 

}

 

-(NSString*)getDeviceInfo

{

    //设备

//    NSLog(@"name: %@", [[UIDevice currentDevice] name]);

//    NSLog(@"systemName: %@", [[UIDevice currentDevice] systemName]);

//    NSLog(@"systemVersion: %@", [[UIDevice currentDevice] systemVersion]);

//    NSLog(@"model: %@", [[UIDevice currentDevice] model]);

//    NSLog(@"localizedModel: %@", [[UIDevice currentDevice] localizedModel]);

    

    NSString *deviceString = [NSStringstringWithFormat:@"\nname: %@\nsystemName: %@\nsystemVersion: %@\nmodel: %@\nlocalizedModel: %@",[[UIDevicecurrentDevice] name],[[UIDevicecurrentDevice] systemName],[[UIDevicecurrentDevice] systemVersion],[[UIDevicecurrentDevice] model],[[UIDevicecurrentDevice] localizedModel]];

    

    return deviceString;

}

 

//可通过苹果review

- (NSString*)getDeviceModel

{

    size_t size;

    sysctlbyname("hw.machine", NULL, &size, NULL, 0);

    char *machine = (char*)malloc(size);

    sysctlbyname("hw.machine", machine, &size, NULL, 0);

    NSString *platform = [NSStringstringWithCString:machine encoding:NSUTF8StringEncoding];

    

    //NSString *platform = [NSStringstringWithUTF8String:machine];二者等效

    free(machine);

    return platform;

}

 

- (NSString *) platformString

{

    NSString *platform = [self getDeviceModel];

    if ([platform isEqualToString:@"iPhone4,1"])     return@"iPhone4 WiFi";

    if ([platform isEqualToString:@"iPhone4,2"])     return @"iPhone4 GSM";

    if ([platform isEqualToString:@"iPhone4,3"])     return@"iPhone4 CDMA";

    if ([platform isEqualToString:@"iPhone4S,1"])     return@"iPhone4S WiFi";

    if ([platform isEqualToString:@"iPhone4S,2"])     return@"iPhone4S GSM";

    if ([platform isEqualToString:@"iPhone4S,3"])     return@"iPhone4S CDMA";

    if ([platform isEqualToString:@"iPhone5,1"])     return@"iPhone5 WiFi";

    if ([platform isEqualToString:@"iPhone5,2"])     return @"iPhone5 GSM";

    if ([platform isEqualToString:@"iPhone5,3"])     return@"iPhone5 CDMA";

    if ([platform isEqualToString:@"iPhone5S,1"])     return@"iPhone5S WiFi";

    if ([platform isEqualToString:@"iPhone5S,2"])     return@"iPhone5S GSM";

    if ([platform isEqualToString:@"iPhone5S,3"])     return@"iPhone5S CDMA";

    return platform;

}

 

转载于:https://www.cnblogs.com/tanwen1989/p/3600061.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值