IOS obtains device information

Source: Internet
Author: User

IOS obtains device information
Generally, IOS obtains device information through the methods of UIDevice, UIScreen, NSBundle, and NSLocal. If you want to obtain the memory and processor information of the device, it seems that you can obtain information similar to Unix.

UIDevice provides a variety of attributes, class functions, and status notifications, including detecting battery usage and locating devices and proximity sensing. What UIDevice does is to provide users and device information for applications. The UIDevice class can also collect various details about devices, such as models and iOS versions. Most of these attributes play a positive role in assisting development.


Sample Code
-(Void) getDeviceInfo {UIDevice * curDev = [UIDevice currentDevice];/** device system information * // device name NSLog (@ "\ tname: % @", curDev. name); // NSLog (@ "\ tmodel: % @", curDev. model); // NSLog (@ "\ tlocalize: % @", curDev. localizedModel); // The system name NSLog (@ "\ tos name: % @", curDev. systemName); // System version NSLog (@ "\ tos version: % @", curDev. systemVersion); // device type: Mobile Phone, tablet switch (curDev. userInterfaceIdiom) {cas E UIUserInterfaceIdiomPhone: NSLog (@ "\ tIdiom: iPhone"); break; case UIUserInterfaceIdiomPad: NSLog (@ "\ tIdiom: iPad"); break; default: NSLog (@ "\ tIdiom: Unknow"); break;} // NSLog (@ "\ tUUID: % @", curDev. identifierForVendor. UUIDString);/** device direction * // switch (curDev. orientation) {case UIDeviceOrientationPortrait: NSLog (@ "\ torientation: Portrait"); break; case UIDeviceOrientationPort RaitUpsideDown: NSLog (@ "\ torientation: upside down"); break; case when: NSLog (@ "\ torientation: left"); break; case UIDeviceOrientationLandscapeRight: NSLog (@ "\ torientation: right"); break; case UIDeviceOrientationFaceUp: NSLog (@ "\ torientation: face up"); break; case UIDeviceOrientationFaceDown: NSLog (@ "\ torientation: face down "); break; default: NSLog (@" \ torientati On: Unknow "); break;} UIScreen * mainScreen = [UIScreen mainScreen]; // screen size NSLog (@" screen size: %. 0fx %. 0f ", mainScreen. bounds. size. width, mainScreen. bounds. size. height);/** device Battery */NSLog (@ "Battery infomation"); // power NSLog (@ "\ tlevel: %. 2f % ", curDev. batteryLevel * 100); switch (curDev. batteryState) {case UIDeviceBatteryStateUnplugged: NSLog (@ "\ tstate: Unplugged"); break; case UIDeviceBattery StateCharging: NSLog (@ "\ tstate: Charging"); break; case UIDeviceBatteryStateFull: NSLog (@ "\ tstate: Full"); break; default: NSLog (@ "\ tstate: unknow "); break;} // whether the battery monitor is enabled if (curDev. isBatteryMonitoringEnabled) {NSLog (@ "\ tmonitor on: YES");} else {NSLog (@ "\ tmonitor on: NO ");} /** somatosensory device */NSLog (@ "Proximity Sensor infomation"); if (curDev. proximityState) {NSLog (@ "\ tsensor on: YES");} el Se {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; cfbundle#versionstring =" 1.0 "; CFBundleSignature = "???? "; Outputs = (iPhoneSimulator); CFBundleVersion = 1; DTPlatformName = iphonesimulator; DTSDKName =" iphonesimulator8.1 "; outputs = 1; UIDeviceFamily = (1); outputs = LaunchScreen; UIMainStoryboardFile = Main; UIRequiredDeviceCapabilities = (armv7); UISupportedInterfaceOrientations = (UIInterfaceOrientationPortrait, UIInterfaceOrientationLandscapeLeft, UIInterfaceOrientationLandscapeRight );*/}


Related Article

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.