zoukankan      html  css  js  c++  java
  • 获取设备型号、app信息、系统信息

    一、 获取设备型号的方法主要有三种:

    ///===== 设备型号:方法一 ========

    NSString * strModel  = [UIDevice currentDevice].model;
    NSLog(@"model:%@",strModel);
    NSLog(@"localizedModel: %@", [[UIDevice currentDevice] localizedModel]);
    

    //===== 设备型号:方法二 =========

    struct utsname systemInfo;
    uname(&systemInfo);
    NSString *deviceString = [NSString stringWithCString:systemInfo.machine encoding:NSUTF8StringEncoding];
    NSLog(@"systemInfo.machine:%@",deviceString);
    

    //===== 设备型号:方法三 (model)=========

    size_t size;
    sysctlbyname ("hw.machine" , NULL , &size ,NULL ,0);
    char *model = (char *)malloc(size);
    sysctlbyname ("hw.machine" , model , &size ,NULL ,0);
    NSString * strModel3 = [NSString stringWithCString: model encoding:NSUTF8StringEncoding];
    free(model);
    NSLog(@"hw.machine-model:%@",strModel3);
    

    //===== 设备型号:方法三 (machine)=========

    char *machine = (char*)malloc(size);
    sysctlbyname("hw.machine", machine, &size, NULL, 0);
     NSString *platform = [NSString stringWithCString:machine encoding:NSUTF8StringEncoding];
    free(machine);
    NSLog(@"hw.machine-platform:%@",platform);
    
  • 相关阅读:
    今日总结
    今日总结
    团队绩效1
    本周总结
    团队冲刺阶段10
    团队冲刺阶段9
    团队冲刺阶段8
    promise手写自定义封装异步任务回调的执行
    Vue中this.$options.data()和this.$data知多少?
    手写Promise自定义封装 then 函数
  • 原文地址:https://www.cnblogs.com/newBlash/p/4288138.html
Copyright © 2011-2022 走看看