Determine device (iPhone, iPod Touch) with iOS

后端 未结 30 1760
礼貌的吻别
礼貌的吻别 2020-11-21 11:29

Is there a way to determine the device running an application. I want to distinguish between iPhone and iPod Touch, if possible.

30条回答
  •  孤独总比滥情好
    2020-11-21 12:15

    Here's a minor update with new models:

    - (NSString *) platformString{
        NSString *platform = [self platform];
        if ([platform isEqualToString:@"iPhone1,1"]) return @"iPhone 1G";
        if ([platform isEqualToString:@"iPhone1,2"]) return @"iPhone 3G";
        if ([platform isEqualToString:@"iPhone2,1"]) return @"iPhone 3GS";
        if ([platform isEqualToString:@"iPhone3,1"]) return @"iPhone 4";
        if ([platform isEqualToString:@"iPod1,1"])   return @"iPod Touch 1G";
        if ([platform isEqualToString:@"iPod2,1"])   return @"iPod Touch 2G";
        if ([platform isEqualToString:@"iPod3,1"])   return @"iPod Touch 3G";
        if ([platform isEqualToString:@"i386"])   return @"iPhone Simulator";
        return platform;
    }
    

提交回复
热议问题