Calling “sysctlbyname(…)” with “hw.machine” flag in iOS9

主宰稳场 提交于 2019-12-03 16:00:14

Yes,I have tested it Using Xcode7 beta5 in iPhone5(iOS9 beta5 installed,not simulator).

+(NSString *) getDeviceModel {
    size_t size;
    sysctlbyname("hw.machine", NULL, &size, NULL, 0);
    char *model = malloc(size);
    sysctlbyname("hw.machine", model, &size, NULL, 0);
    NSString *deviceModel = [NSString stringWithCString:model encoding:NSUTF8StringEncoding];
    free(model);
    return deviceModel;
}

And the returning value is "iPhone5,2".So I thought the device name is not affected by restriction on the "sysctl" function.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!