Before the second, add a content. Uidevice is not available for specific device models.
To get the device model, such as (iphone 4s, iphone5), this way.
1. Introduce the header file.
#include <sys/types.h>
#include <sys/sysctl.h>
2. Get the Model
Phone model. size_t size; Sysctlbyname ("Hw.machine", null, &size, null, 0); Char *machine = (char*) malloc (size); Sysctlbyname ("Hw.machine", Machine, &size, NULL, 0); NSString *platform = [NSString stringwithcstring:machine encoding:nsutf8stringencoding];
The platform you get here is a device model. Like iphone5,2.
So if you want to be more perfect, you can judge by the string yourself.
For example: if ([Platform isequaltostring:@ "iphone3,1"]) return @ "IPhone 4";
I. Uidevice
Device-related information acquisition nsstring *strname = [[Uidevice currentdevice] name]; NSLog (@ "Device Name:%@", strName);e.g. "My iPhone" nsstring *strid = [[Uidevice currentdevice] uniqueidentifier]; NSLog (@ "Device Unique ID:%@", Strid);uuid,5.0 not available after nsstring *strsysname = [[Uidevice currentdevice] systemName]; NSLog (@ "System name:%@", strsysname);e.g. @ "IOS" nsstring *strsysversion = [[Uidevice currentdevice] systemversion]; NSLog (@ "System version number:%@", strsysversion);e.g. @ "4.0" nsstring *strmodel = [[Uidevice currentdevice] model]; NSLog (@ "Device mode:%@", Strmodel); //e.g. @ "IPhone" @ "IPod touch" nsstring *strlocmodel = [[Uidevice currentdevice] Localizedmodel]; NSLog (@ "Local device mode:%@", Strlocmodel); Localized version of Model //local model (internationalized Zone name) nsstring* Phonemodel = [[Uidevice currentdevice] model]; NSLog (@ "mobile phone Model:%@", Phonemodel); //Phone model
01-12 iOS get phone with screen properties