[IOS] Get the specific device model information
Address; http://blog.csdn.net/zhaoyabei/article/details/46697859
In application statistics, you sometimes need to upload the device model:
[[UIDevice currentDevice] model]
The device model obtained is not a specific model. For example, if you run it on the iPhone 5S, the measured string is @ "iPhone". What I want is a specific model.
Here we provide a method to obtain the specific device model (the correspondence between the version and model comes from Wikipedia ):
-(NSString *) platform {struct utsname systemInfo; uname (& systemInfo); NSString * deviceString = [NSString stringWithCString: systemInfo. machine encoding: NSUTF8StringEncoding]; // older devices such as iPhone 3 are not considered, and iPad devices are not considered (the company's applications do not support iPad) if ([deviceString hasPrefix: @ iPhone3]) return @ iPhone 4; if ([deviceString isEqualToString: @ iPhone4, 1]) return @ iPhone 4S; if ([deviceString isEqualToString: @ iPhone5, 1] | [deviceString isEqualToString: @ iPhone5, 2]) return @ iPhone 5; if ([deviceString isEqualToString: @ iPhone5, 3] | [deviceString isEqualToString: @ iPhone5, 4]) return @ iPhone 5C; if ([deviceString hasPrefix: @ iPhone6]) return @ iPhone 5S; if ([deviceString isEqualToString: @ iPhone7, 1]) return @ iPhone 6 Plus; if ([deviceString is: tostring: @ iPhone7, 2]) return @ iPhone 6; if ([deviceString isEqualToString: @ i386]) return @ Simulator; if ([deviceString isEqualToString: @ x86_64]) return @ Simulator; // if no match exists, return the type "return deviceString" provided by the system, such as @ iPhone5 and 3 ;}