iOS get phone-related information

Source: Internet
Author: User

iOS Specific device model:

#include <sys/types.h><sys/sysctl.h>
- (void) Test {//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]; NSLog (@"%@", platform); //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"; //Note: The emulator runs on the different}

Uidevice: Get Phone properties

- (void) Device {//[[Uidevice Currentdevice] systemName];//System name//[[Uidevice Currentdevice] systemversion];//Version number//[[Uidevice Currentdevice] model];//type, simulator, real machine//[[Uidevice Currentdevice] name];//Device Name//[[Uidevice Currentdevice] localizedmodel];//Local mode//access to equipment-related informationNSString *strname =[[Uidevice Currentdevice] name]; NSLog (@"device Name:%@", strName);//e.g. "My IPhone"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 region name)NSString* Phonemodel =[[Uidevice Currentdevice] model]; NSLog (@"phone Model:%@", Phonemodel);//Phone Model}

NSBundle: Get the app name version number

- (void) Bundle {//access to App-related informationNsdictionary *dicinfo =[[NSBundle Mainbundle] infodictionary]; //cfshow (dicinfo);NSString*strappname = [Dicinfo objectforkey:@"Cfbundledisplayname"]; NSLog (@"app Name:%@", strappname);//Current app nameNSString*strappversion = [Dicinfo objectforkey:@"cfbundleshortversionstring"]; NSLog (@"app version:%@", strappversion);//Current application version such as: 1.0.1NSString*strappbuild = [Dicinfo objectforkey:@"cfbundleversion"]; NSLog (@"App build version:%@", Strappbuild);//Current app version number int type}

Nslocale: Get machine Current language and country

-(void) locale {        //Getting The User ' s Language    nsarray *languagearray = [Nslocale preferredlanguages];     *language = [Languagearray objectatindex:0];    NSLog (@ " language:%@", language);         *locale = [Nslocale Currentlocale];     *country = [locale localeidentifier];    NSLog (@ " Country:%@", Country);}

iOS get phone-related information

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.