DeviceInfo-设备信息

来源:互联网 发布:golang java性能对比 编辑:程序博客网 时间:2024/05/16 10:57
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {    //当前设备    UIDevice *dev = [UIDevice currentDevice];    //开启电池监控    [[UIDevice currentDevice] setBatteryMonitoringEnabled:YES];    NSString *name = dev.name;    NSString *model = dev.model;    NSString *localizedModel = dev.localizedModel;    NSString *systemName = dev.systemName;    NSString *systemVersion = dev.systemVersion;    NSString *uuid = [dev.identifierForVendor UUIDString];    float batteryLevel = dev.batteryLevel;    UIDeviceBatteryState bState = dev.batteryState;    NSLog(@"name = %@\nmodel = %@\nlocalizeModel = %@\nsystemName = %@\nsystemVersion = %@\nuuid = %@", name, model, localizedModel, systemName, systemVersion, uuid);    switch (bState) {        case UIDeviceBatteryStateCharging:            NSLog(@"充电中");            break;        case UIDeviceBatteryStateFull:            NSLog(@"已充满");            break;        case UIDeviceBatteryStateUnplugged:            NSLog(@"未充电");            break;        case UIDeviceBatteryStateUnknown:            NSLog(@"状态未知");            break;    }    NSLog(@"电量状态: %.2f%%", batteryLevel * 100);    return YES;}
0 0
原创粉丝点击