Return iOS device model number

前端 未结 3 1045
醉梦人生
醉梦人生 2021-01-26 13:35

There are a number of answers to find the device name (iPhone 2,1; etc). (iOS - How to get device make and model?)

I\'d like to find a way to return the device model (M

相关标签:
3条回答
  • 2021-01-26 14:01

    It isn't possible, unfortunately.

    As of now, the only to get the device's color is using a private API (like described in this answer).

    0 讨论(0)
  • 2021-01-26 14:06

    Include the following directive

    #include <sys/sysctl.h>
    

    Implement the following method

    -(NSString*)hwModel
    {
        size_t size;
        char *kHwModel = "hw.model";
        sysctlbyname(kHwModel, NULL, &size, NULL, 0);
    
        char *answer = malloc(size);
        sysctlbyname(kHwModel, answer, &size, NULL, 0);
    
        NSString *results = [NSString stringWithCString:answer encoding: NSUTF8StringEncoding];
    
        free(answer);
        return results;
    }
    

    and in call the above method as follows:-

    [self hwModel];
    
    0 讨论(0)
  • 2021-01-26 14:08

    You can try to get the serial numbers,I remember that some letter is to determine the phone color, but I not sure.

    0 讨论(0)
提交回复
热议问题