UIDevice currentDevice model possible values,

Source: Internet
Author: User

UIDevice currentDevice model possible values,

NOTE:The below code may not contain in all device's string, I'm with other guys are maintaining the same code onGitHubSo please take the latest code from there

Objective-C: GitHub/DeviceUtil

Swift: GitHub/DeviceGuru

#include <sys/types.h>#include <sys/sysctl.h>- (NSString*)hardwareDescription {    NSString *hardware = [self hardwareString];    if ([hardware isEqualToString:@"iPhone1,1"]) return @"iPhone 2G";    if ([hardware isEqualToString:@"iPhone1,2"]) return @"iPhone 3G";    if ([hardware isEqualToString:@"iPhone3,1"]) return @"iPhone 4";    if ([hardware isEqualToString:@"iPhone4,1"]) return @"iPhone 4S";    if ([hardware isEqualToString:@"iPhone5,1"]) return @"iPhone 5";    if ([hardware isEqualToString:@"iPod1,1"]) return @"iPodTouch 1G";    if ([hardware isEqualToString:@"iPod2,1"]) return @"iPodTouch 2G";    if ([hardware isEqualToString:@"iPad1,1"]) return @"iPad";    if ([hardware isEqualToString:@"iPad2,6"]) return @"iPad Mini";    if ([hardware isEqualToString:@"iPad4,1"]) return @"iPad Air WIFI";    //there are lots of other strings too, checkout the github repo    //link is given at the top of this answer    if ([hardware isEqualToString:@"i386"]) return @"Simulator";    if ([hardware isEqualToString:@"x86_64"]) return @"Simulator";    return nil;}- (NSString*)hardwareString {    size_t size = 100;    char *hw_machine = malloc(size);    int name[] = {CTL_HW,HW_MACHINE};    sysctl(name, 2, hw_machine, &size, NULL, 0);    NSString *hardware = [NSString stringWithUTF8String:hw_machine];    free(hw_machine);    return hardware;}

Link: https://stackoverflow.com/questions/14411075/uidevice-currentdevice-model-possible-values

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.