iOS Get device information

Source: Internet
Author: User

ProfileiOS Get device information is generally through uidevice,uiscreen,nsbundle,nslocal, and so on, if you want to get the device's memory, processor information, it seems to be able to obtain similar information in UNIX way.

Uidevice provides a variety of properties, class functions, and status notifications, including detection of battery power and positioning equipment and proximity sensing, Uidevice The job is to provide users and devices with some information about the application. the uidevice class is also capable of collecting specific details about the device, such as the model and IOS version. Most of these properties have a positive effect on development work


code Example
-(void) getdeviceinfo{uidevice* curdev = [Uidevice currentdevice];    /** Device System Information *//Device name NSLog (@ "\tname:%@", curdev.name);    Device mode NSLog (@ "\tmodel:%@", Curdev.model);    Device Local mode NSLog (@ "\tlocalize:%@", Curdev.localizedmodel);    System name NSLog (@ "\tos name:%@", curdev.systemname);    System version number NSLog (@ "\tos version:%@", curdev.systemversion); Device Category: Mobile, tablet switch (CURDEV.USERINTERFACEIDIOM) {case Uiuserinterfaceidiomphone:nslog (@ "\tidi            Om:iphone ");        Break            Case Uiuserinterfaceidiompad:nslog (@ "\tidiom:ipad");                    Break            Default:nslog (@ "\tidiom:unknow");    Break        }//Device uniquely identifies NSLog (@ "\tuuid:%@", curDev.identifierForVendor.UUIDString); /** Device Direction *//device toward switch (curdev.orientation) {case Uideviceorientationportrait:nslog @ "\to Rientation:portrAit ");        Break            Case Uideviceorientationportraitupsidedown:nslog (@ "\torientation:upside");        Break            Case Uideviceorientationlandscapeleft:nslog (@ "\torientation:left");        Break            Case Uideviceorientationlandscaperight:nslog (@ "\torientation:right");        Break            Case Uideviceorientationfaceup:nslog (@ "\torientation:face up");        Break            Case Uideviceorientationfacedown:nslog (@ "\torientation:face");        Break            Default:nslog (@ "\torientation:unknow");    Break    } uiscreen* mainscreen = [UIScreen mainscreen];        Screen size NSLog (@ "Screens size:%.0fx%.0f", MainScreen.bounds.size.width, MainScreen.bounds.size.height);        /** Device Battery */NSLog (@ "Battery infomation");    Battery NSLog (@ "\tlevel:%.2f%%", curdev.batterylevel*100); Switch (curdev.batterystate) {case UidevicEbatterystateunplugged:nslog (@ "\tstate:unplugged");        Break            Case Uidevicebatterystatecharging:nslog (@ "\tstate:charging");        Break            Case Uidevicebatterystatefull:nslog (@ "\tstate:full");        Break            Default:nslog (@ "\tstate:unknow");    Break    }//battery monitor whether to turn on if (curdev.isbatterymonitoringenabled) {NSLog (@ "\tmonitor on:yes");    } else {NSLog (@ "\tmonitor on:no");    }/** Body Sensor */NSLog (@ "Proximity Sensor infomation");    if (curdev.proximitystate) {NSLog (@ "\tsensor on:yes");    } else {NSLog (@ "\tsensor on:no");    } if (curdev.proximitymonitoringenabled) {NSLog (@ "\tmonitor on:yes");    } else {NSLog (@ "\tmonitor on:no");    }}-(void) getbundleinfo{nsbundle* bundle = [NSBundle mainbundle]; nsdictionary* bundleinfo = [Bundle infodictiOnary];        Application Information NSLog (@ "%@", bundleinfo);    /* cfbundledevelopmentregion = en;    cfbundleexecutable = DeviceInfo;    Cfbundleidentifier = "Arbboter.com.DeviceInfo";    Cfbundleinfodictionaryversion = "6.0";    Cfbundleinfoplisturl = "Info.plist-file:///../DeviceInfo.app/";    Cfbundlename = DeviceInfo;    Cfbundlenumericversion = 16809984;    Cfbundlepackagetype = APPL;    cfbundleshortversionstring = "1.0";    Cfbundlesignature = "????";                                      Cfbundlesupportedplatforms = (iphonesimulator    );    Cfbundleversion = 1;    Dtplatformname = Iphonesimulator;    Dtsdkname = "iphonesimulator8.1";    Lsrequiresiphoneos = 1;    uidevicefamily = (1);    Uilaunchstoryboardname = Launchscreen;    Uimainstoryboardfile = Main;                                        Uirequireddevicecapabilities = (armv7);                                            Uisupportedinterfaceorientations = (uiinterfaceorientationportrait, Uiinterfaceorientationlandscapeleft, Uiint    Erfaceorientationlandscaperight); */}


iOS Get device 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.