iOS Development Get mobile info (Uidevice,nsbundle,nslocale)

Source: Internet
Author: User

In development, it is necessary to obtain some information about the current device, which can be obtained through Uidevice,nsbundle,nslocale.

Uidevice

Uidevice provides a variety of properties, class functions and status notifications, which can detect cell phone power, positioning, sensing, model, current system version and so on.

Device-related information acquisition   nsstring *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];   

NSBundle 

A bundle is a directory that contains the resources the program uses, including images, sounds, compiled code, and some application information.

/app application-related information acquisition      nsdictionary *dicinfo = [[NSBundle mainbundle] infodictionary];    cfshow (dicinfo);            NSString *strappname = [Dicinfo objectforkey:@ "Cfbundledisplayname"];      NSLog (@ "app app Name:%@", strappname);            NSString *strappversion = [Dicinfo objectforkey:@ "cfbundleshortversionstring"];      NSLog (@ "app version:%@", strappversion);            NSString *strappbuild = [Dicinfo objectforkey:@ "cfbundleversion"];      

Nslocale 

Nslocale can obtain the user's localization information, such as currency, language, country, number, date format, location display and so on.

1 //Getting The User ' s Language2Nsarray *languagearray =[Nslocale preferredlanguages]; 3NSString *language = [Languagearray objectatindex:0]; 4NSLog (@"Language:%@", language);//en5      6Nslocale *locale =[Nslocale Currentlocale]; 7NSString *country =[locale Localeidentifier]; 8NSLog (@"Country:%@", country);//en_US

iOS Development Get mobile info (Uidevice,nsbundle,nslocale)

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.