- 系统名称
+ (NSString *)getDeviceSystemName {
return [[UIDevice currentDevice]systemName];
}
- 系统版本号
+ (NSString *)getDeviceSystemVersion {
return [[UIDevice currentDevice]systemVersion];
}
- 设备内存
+ (CGFloat)getDeviceTotalMemory {
return ceil([NSProcessInfo processInfo].physicalMemory/(1024.0*1024.0)*10)/10;
}
- 设备电量
+ (CGFloat)getDeviceBatteryLevel{
[UIDevice currentDevice].batteryMonitoringEnabled = YES;
return ceil([UIDevice currentDevice].batteryLevel*100)/100;
}
- 是否开启WiFi
+ (BOOL)deviceisWiFiEnabled {
NSCountedSet * cset = [NSCountedSet new];
struct ifaddrs *interfaces;
if( ! getifaddrs(&interfaces) ) {
for( struct ifaddrs *interface = interfaces; interface; interface = interface->ifa_next) {
if ( (interface->ifa_flags & IFF_UP) == IFF_UP ) {
[cset addObject:[NSString stringWithUTF8String:interface->ifa_name]];
}
}
}
return [cset countForObject:@"awdl0"] > 1 ? YES : NO;
}
- 是否模拟器
+ (BOOL)deviceIsSimulator {
return TARGET_IPHONE_SIMULATOR;
}
iOS获取常用设备信息
最新推荐文章于 2024-05-21 22:03:06 发布