获取系统的iOS版本
#import "sys/utsname.h" //这个加不加都没影响
[[[UIDevice currentDevice] systemVersion] floatValue];
6.0以下获取系统的唯一标识uuid(为了系统安全考虑,6.0以后此方法被DEPRECATED)
[[UIDevice currentDevice] uniqueIdentifier]; //真实的uuid
6.0及其以上获取系统唯一标识(这个不是物理uuid,只是名字叫UUID而已,)
,[[[UIDevice currentDevice] identifierForVendor] UUIDString];
综上:
NSLog(@"%f",[[[UIDevice currentDevice] systemVersion] floatValue]);
if ([[[UIDevice currentDevice] systemVersion] floatValue]<6.0) {
NSLog(@"%@",[[UIDevice currentDevice] uniqueIdentifier]); //真实uuid
}else //6.0及其以上
{
NSLog(@"6.0 %@",[[[UIDevice currentDevice] identifierForVendor] UUIDString]);
}
此外,UIDevice类还有如下属性:
+ (UIDevice *)currentDevice;
@property(nonatomic,readonly,retain) NSString *name; // e.g. "My iPhone"
@property(nonatomic,readonly,retain) NSString *model; // e.g. @"iPhone", @"iPod touch"
@property(nonatomic,readonly,retain) NSString *localizedModel; // localized version of model
@property(nonatomic,readonly,retain) NSString *systemName; // e.g. @"iOS"
@property(nonatomic,readonly,retain) NSString *systemVersion; // e.g. @"4.0"
@property(nonatomic,readonly) UIDeviceOrientation orientation; // return current device orientation. this will return UIDeviceOrientationUnknown unless device orientation notifications are being generated.
@property(nonatomic,readonly,retain) NSString *uniqueIdentifier NS_DEPRECATED_IOS(2_0, 5_0); // a string unique to each device based on various hardware info.
@property(nonatomic,readonly,retain) NSUUID *identifierForVendor NS_AVAILABLE_IOS(6_0); // a UUID that may be used to uniquely identify the device, same across apps from a single vendor.
@property(nonatomic,readonly,getter=isGeneratingDeviceOrientationNotifications) BOOL generatesDeviceOrientationNotifications;
- (void)beginGeneratingDeviceOrientationNotifications; // nestable
- (void)endGeneratingDeviceOrientationNotifications;
@property(nonatomic,getter=isBatteryMonitoringEnabled) BOOL batteryMonitoringEnabled NS_AVAILABLE_IOS(3_0); // default is NO
@property(nonatomic,readonly) UIDeviceBatteryState batteryState NS_AVAILABLE_IOS(3_0); // UIDeviceBatteryStateUnknown if monitoring disabled
@property(nonatomic,readonly) float batteryLevel NS_AVAILABLE_IOS(3_0); // 0 .. 1.0. -1.0 if UIDeviceBatteryStateUnknown
@property(nonatomic,getter=isProximityMonitoringEnabled) BOOL proximityMonitoringEnabled NS_AVAILABLE_IOS(3_0); // default is NO
@property(nonatomic,readonly) BOOL proximityState NS_AVAILABLE_IOS(3_0); // always returns NO if no proximity detector
@property(nonatomic,readonly,getter=isMultitaskingSupported) BOOL multitaskingSupported NS_AVAILABLE_IOS(4_0);
@property(nonatomic,readonly) UIUserInterfaceIdiom userInterfaceIdiom NS_AVAILABLE_IOS(3_2);
- (void)playInputClick NS_AVAILABLE_IOS(4_2); // Plays a click only if an enabling input view is on-screen and user has enabled input clicks.

被折叠的 条评论
为什么被折叠?



