常用方法1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43
| NSLog(@"HostName: %@", [[NSProcessInfo processInfo] hostName]); NSLog(@"GlobalUniqueString: %@", [[NSProcessInfo processInfo] globallyUniqueString]); NSLog(@"OperatingSystemName: %@", [[NSProcessInfo processInfo] operatingSystemName]); NSLog(@"OperatingSystemVersion: %@", [[NSProcessInfo processInfo] operatingSystemVersionString]); NSLog(@"PhysicalMem: %llu", [[NSProcessInfo processInfo] physicalMemory]); NSLog(@"ProcessName: %@", [[NSProcessInfo processInfo] processName]); NSLog(@"UniqueId: %@", [UIDevice currentDevice].identifierForVendor); NSLog(@"userInterfaceIdiom: %d", [UIDevice currentDevice].userInterfaceIdiom); NSLog(@"Name: %@", [UIDevice currentDevice].name); NSLog(@"SystemName: %@", [UIDevice currentDevice].systemName); NSLog(@"SystemVersion: %@", [UIDevice currentDevice].systemVersion); NSLog(@"Model: %@", [UIDevice currentDevice].model); NSLog(@"LocalizeModel: %@", [UIDevice currentDevice].localizedModel); NSLog(@"BatteryLevel: %f", [UIDevice currentDevice].batteryLevel);
|
2. 判断设备是否是7.0以上系统
[[[UIDevice currentDevice] systemVersion] floatValue] >= 7.0f
注意:
假如我们的设备版本号为7.1.1
(为字符串类型),对其进行floatValue
浮点化后值为7.100000
。
3. 判断设备是否是iPhone、iPad
- iPad:
[[UIDevice currentDevice] userInterfaceIdiom] == UIUserInterfaceIdiomPad
- iPhone:
[[UIDevice currentDevice] userInterfaceIdiom] == UIUserInterfaceIdiomPhone
UIUserInterfaceIdiom in UIDevice.h1 2 3 4 5 6
| typedef NS_ENUM(NSInteger, UIUserInterfaceIdiom) { #if __IPHONE_3_2 <= __IPHONE_OS_VERSION_MAX_ALLOWED UIUserInterfaceIdiomPhone, UIUserInterfaceIdiomPad, #endif };
|