01-12 iOS get phone with screen properties

Source: Internet
Author: User
Tags unique id


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

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.