我们通常用iPhone机型来指明iPhone设备,比如iPhone5。不过,iPhone还有一个机型号码,比如A1428代表使用GSM网络的iPhone5。另外,通过代码还可以提取一个硬件设备代码,比如iPhone5.1。可以根据需要选择合适的识别码。
下表按照从新到旧列出了所有iPhone设备,
| Name | Introduced | Model Number | Hardware Machine |
| iPhone 5 (GSM) | 2012 | A1428 | iPhone5,1 |
| iPhone 5 (CDMA) | 2012 | A1429 | iPhone5,2 |
| iPhone 4S | 2011 | A1387 | iPhone4,1 |
| iPhone 4 (GSM) | 2010 | A1332 | iPhone3,1 |
| iPhone 4 (GSM Rev A) | 2010 | A1332 | iPhone3,2 |
| iPhone 4 (CDMA) | 2011 | A1349 | iPhone3,3 |
| iPhone 3GS | 2009 | A1303 | iPhone2,1 |
| iPhone 3G | 2008 | A1241 | iPhone1,2 |
| iPhone | 2007 | A1203 | iPhone1,1 |
| iPhone Simulator | N/A | N/A | i386 |
机型号码可以在iPhone手机背面找到。要想通过应用程序获得硬件设备代码,可以使用下面的方法。
#include <sys/types.h>
#include <sys/sysctl.h>
- (NSString *)machine
{
size_t size;
// Set 'oldp' parameter to NULL to get the size of the data
// returned so we can allocate appropriate amount of space
sysctlbyname("hw.machine", NULL, &size, NULL, 0);
// Allocate the space to store name
char *name = malloc(size);
// Get the platform name
sysctlbyname("hw.machine", name, &size, NULL, 0);
// Place name into a string
NSString *machine = [NSString stringWithCString:name];
// Done with this
free(name);
return machine;
}
|

本文提供了iPhone设备型号的详细列表,包括从最新款到早期款的所有机型,并解释了如何通过不同的标识符来区分GSM和CDMA版本的iPhone,还提供了一个获取硬件设备代码的示例代码。

1158

被折叠的 条评论
为什么被折叠?



