如何从代码中获取iPhone的模型. (例如MC143C) [英] How to get the model of iPhone from code. (e.g. MC143C)

查看:76
本文介绍了如何从代码中获取iPhone的模型. (例如MC143C)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要从代码中获取iPhone的型号.我可以从我的iPhone中看到型号为"MC143C"的型号,但是当我通过使用代码来检索它时,它会返回"iPhone".这是我用来获取型号的代码.

I need to get the iPhone model number from code. I can see the model number from my iPhone which is "MC143C", but when I am retrieving this by using code it is returning "iPhone". This is the code I am using to get the model number.

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

任何人都可以帮助我获取我想从设备中获取的信息.

Can anyone please help me to have the information i want to get from my device.

谢谢, !ZAQ

推荐答案

导入 https://github.com /erica/uidevice-extension

1. 在UIDevice-IOKitExtensions.h中定义模型编号

1. define modelnumber in UIDevice-IOKitExtensions.h

- (NSString *) modelnumber; 

2. 将以下代码添加到UIDevice-IOKitExtensions.m

2. add the following code to UIDevice-IOKitExtensions.m

- (NSString *) modelnumber{
    NSArray *results = getValue(@"model-number");
    if (results){
        NSString *mn=[[results objectAtIndex:0] copy];
        return  mn;
    }
    return nil;   
}

这篇关于如何从代码中获取iPhone的模型. (例如MC143C)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆