How to obtain the hardware name of an ios device

Source: Internet
Author: User
How to obtain the hardware name of an ios device
1. If you want to obtain the specific device, the first generation of the product must include

# Import "sys/utsname. h"

Is defined as an auxiliary function:

+ (Std: string) getIosDeviceNameAndGeneration
;

Function implementation:

+ (Std: string) getIosDeviceNameAndGeneration

{

Structutsname systemInfo;


Uname (& systemInfo );

NSLog (@ "% @", [NSStringstringWithCString: systemInfo. machineencoding: NSUTF8StringEncoding]);


Return std: string (systemInfo. machine );

}

The structure of utsname is defined as follows:

Struct utsname {
Char sysname [_ sys_namelen];/* [xsi] Name of OS */
Char nodename [_ sys_namelen];/* [xsi] Name of this network node */
Char release [_ sys_namelen];/* [xsi] Release level */
Char version [_ sys_namelen];/* [xsi] version level */
Char Machine [_ sys_namelen];/* [xsi] hardware type */
};


The machine field is the type of hardware, such as ipod2 and 1. This is the second generation of ipod. The specific device needs to parse the string by yourself.


2. If you only need to obtain the hardware type, such

IPhone,

IPod Touch

IPhone SimulatorAnd so on.

+ (STD: string) getiosdevicename;


Implementation:

+ (STD: string) getiosdevicename

{

Nsstring * nsmodelname = [[uidevicecurrentdevice] model];

Return [nsmodelname
Utf8string];

}


The machineName value is as follows: "iPhone1, 1" => "iPhone 1G ",

"IPhone1, 2" => "iPhone 3G ",

"IPhone E2, 1" => "iPhone 3GS ",

"IPhone3, 1" => "iPhone 4 ",

"IPhone3, 2" => "iPhone 4 Verizon ",

"IPhone3, 3" => "iPhone 4 CDMA ",

"IPhone4, 1" => "iPhone 4 S ",


"IPod1, 1" => "iPod Touch 1G ",

"IPod2, 1" => "iPod Touch 2G ",

"IPod3, 1" => "iPod Touch 3G ",

"IPod4, 1" => "iPod Touch 4G ",


"IPad1, 1" => "iPad ",

"IPad2, 1" => "iPad 2 (WiFi )",

"IPad2, 2" => "iPad 2 (GSM )",

"IPad2, 3" => "iPad 2 (CDMA )",


Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.