iOS get device and app information

Source: Internet
Author: User
Tags locale unique id

The iOS SDK provides classes such as Uidevice,nsbundle,nslocale,uiscreen to get information about devices, apps, and more.

Uidevice is used to obtain device-specific information such as device name, device unique ID, system name, system version number, device mode, local device mode, and so on.

NSBundle is used to get information about the app, such as app name, app version, app build version, and more.

Nslocale is used to obtain the user's localization information settings, such as currency type, country, language, number, format of date format, provide correct geographical location display, etc.

The UIScreen is used to obtain the screen size and resolution of the device.

The corresponding code is as follows:

Access to equipment-related information
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

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

Access to app-related information
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"];
NSLog (@ "app build version:%@", strappbuild);

Getting the User ' s Language
Nsarray *languagearray = [Nslocale preferredlanguages];
NSString *language = [Languagearray objectatindex:0];
NSLog (@ "Language:%@", language);//en

Nslocale *locale = [Nslocale Currentlocale];
NSString *country = [locale localeidentifier];
NSLog (@ "Country:%@", country); en_US

Screen size

CGRect rect = [[UIScreen mainscreen] bounds];

Cgsize size = rect.size;

CGFloat width = size.width;

CGFloat height = size.height;

NSLog (@ "width, height:%f,%f", width,height);

Resolution

CGFloat scale_screen = [UIScreen mainscreen].scale;

NSLog (@ "screen w:%f", width*scale_screen);

NSLog (@ "screen h:%f", height*scale_screen);

Reference:

http://blog.csdn.net/xyz_lmn/article/details/8968196

http://blog.csdn.net/tangaowen/article/details/7597535

iOS get device and app 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.