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 );*/}