美文网首页
iOS「设备标识与名称对应关系」获取函数源码(持续更新-最新更新

iOS「设备标识与名称对应关系」获取函数源码(持续更新-最新更新

作者: Chriszzzz | 来源:发表于2020-04-01 18:20 被阅读0次

    包含iPhone、iPod、iPad(iPad/Air/Pro/Mini)、Simulator的设备对应关系。
    最新更新:2020年04月21日
    信息确认参考:iOS设备标识与名称官方对应关系的确认办法

    + (NSString *)iosDeviceAnnounceTypeWithPreciseType:(NSString *)preciseType {
        
        NSString *transType = nil;
        
        transType = [self _iphoneAnnounceTypeWithPreciseType:preciseType];
        if (nil != transType) {
            return transType;
        }
        
        transType = [self _ipodAnnounceTypeWithPreciseType:preciseType];
        if (nil != transType) {
            return transType;
        }
        
        transType = [self _ipadAnnounceTypeWithPreciseType:preciseType];
        if (nil != transType) {
            return transType;
        }
        
        transType = [self _ipadAirAnnounceTypeWithPreciseType:preciseType];
        if (nil != transType) {
            return transType;
        }
    
        transType = [self _ipadProAnnounceTypeWithPreciseType:preciseType];
        if (nil != transType) {
            return transType;
        }
    
        transType = [self _ipadMiniAnnounceTypeWithPreciseType:preciseType];
        if (nil != transType) {
            return transType;
        }
    
        transType = [self _simulatorAnnounceTypeWithPreciseType:preciseType];
        if (nil != transType) {
            return transType;
        }
        
        return preciseType;
    }
    
    #define __typePair(appleStr, publicStr) \
    if ([preciseType isEqualToString:appleStr]) { return publicStr; }
    
    + (NSString *)_iphoneAnnounceTypeWithPreciseType:(NSString *)preciseType {
        
        __typePair(@"iPhone1,1", @"iPhone 2G")
        __typePair(@"iPhone1,2", @"iPhone 3G")
        __typePair(@"iPhone2,1", @"iPhone 3GS")
        __typePair(@"iPhone3,1", @"iPhone 4")
        __typePair(@"iPhone3,2", @"iPhone 4")
        __typePair(@"iPhone3,3", @"iPhone 4")
        __typePair(@"iPhone4,1", @"iPhone 4S")
        __typePair(@"iPhone5,1", @"iPhone 5")
        __typePair(@"iPhone5,2", @"iPhone 5")
        __typePair(@"iPhone5,3", @"iPhone 5c")
        __typePair(@"iPhone5,4", @"iPhone 5c")
        __typePair(@"iPhone6,1", @"iPhone 5s")
        __typePair(@"iPhone6,2", @"iPhone 5s")
        
        __typePair(@"iPhone7,2", @"iPhone 6")
        __typePair(@"iPhone7,1", @"iPhone 6 Plus")
        __typePair(@"iPhone8,1", @"iPhone 6s")
        __typePair(@"iPhone8,2", @"iPhone 6s Plus")
        __typePair(@"iPhone8,4", @"iPhone SE")
        __typePair(@"iPhone9,1", @"iPhone 7")
        __typePair(@"iPhone9,3", @"iPhone 7")
        __typePair(@"iPhone9,2", @"iPhone 7 Plus")
        __typePair(@"iPhone9,4", @"iPhone 7 Plus")
        
        __typePair(@"iPhone10,1", @"iPhone 8")
        __typePair(@"iPhone10,4", @"iPhone 8")
        __typePair(@"iPhone10,2", @"iPhone 8 Plus")
        __typePair(@"iPhone10,5", @"iPhone 8 Plus")
        __typePair(@"iPhone10,3", @"iPhone X")
        __typePair(@"iPhone10,6", @"iPhone X")
        __typePair(@"iPhone11,8", @"iPhone XR")
        __typePair(@"iPhone11,2", @"iPhone XS")
        __typePair(@"iPhone11,4", @"iPhone XS Max")
        __typePair(@"iPhone11,6", @"iPhone XS Max")
        
        __typePair(@"iPhone12,1", @"iPhone 11")
        __typePair(@"iPhone12,3", @"iPhone 11 Pro")
        __typePair(@"iPhone12,5", @"iPhone 11 Pro Max")
        __typePair(@"iPhone12,8", @"iPhone SE 2G")
            
        return nil;
    }
    
    + (NSString *)_ipodAnnounceTypeWithPreciseType:(NSString *)preciseType {
        
        __typePair(@"iPod1,1", @"iPod Touch 1G")
        __typePair(@"iPod2,1", @"iPod Touch 2G")
        __typePair(@"iPod3,1", @"iPod Touch 3G")
        __typePair(@"iPod4,1", @"iPod Touch 4G")
        __typePair(@"iPod5,1", @"iPod Touch 5G")
        __typePair(@"iPod7,1", @"iPod Touch 6G")
        __typePair(@"iPod9,1", @"iPod Touch 7G")
    
        return nil;
    }
    
    + (NSString *)_ipadAnnounceTypeWithPreciseType:(NSString *)preciseType {
        
        __typePair(@"iPad1,1", @"iPad 1G")
        __typePair(@"iPad2,1", @"iPad 2G")
        __typePair(@"iPad2,2", @"iPad 2G")
        __typePair(@"iPad2,3", @"iPad 2G")
        __typePair(@"iPad2,4", @"iPad 2G")
        __typePair(@"iPad3,1", @"iPad 3G")
        __typePair(@"iPad3,2", @"iPad 3G")
        __typePair(@"iPad3,3", @"iPad 3G")
        __typePair(@"iPad3,4", @"iPad 4G")
        __typePair(@"iPad3,5", @"iPad 4G")
        __typePair(@"iPad3,6", @"iPad 4G")
    
        __typePair(@"iPad6,11", @"iPad 5G")
        __typePair(@"iPad6,12", @"iPad 5G")
        __typePair(@"iPad7,5", @"iPad 6G")
        __typePair(@"iPad7,6", @"iPad 6G")
        __typePair(@"iPad7,11", @"iPad 7G")
        __typePair(@"iPad7,12", @"iPad 7G")
        
        return nil;
    }
    
    + (NSString *)_ipadAirAnnounceTypeWithPreciseType:(NSString *)preciseType {
        
        __typePair(@"iPad4,1", @"iPad Air")
        __typePair(@"iPad4,2", @"iPad Air")
        __typePair(@"iPad4,3", @"iPad Air")
        __typePair(@"iPad5,3", @"iPad Air 2G")
        __typePair(@"iPad5,4", @"iPad Air 2G")
        __typePair(@"iPad11,3", @"iPad Air 3G")
        __typePair(@"iPad11,4", @"iPad Air 3G")
        
        return nil;
    }
    
    + (NSString *)_ipadProAnnounceTypeWithPreciseType:(NSString *)preciseType {
        
        __typePair(@"iPad6,3", @"iPad Pro 9.7-inch")
        __typePair(@"iPad6,4", @"iPad Pro 9.7-inch")
        
        __typePair(@"iPad7,3", @"iPad Pro 10.5-inch")
        __typePair(@"iPad7,4", @"iPad Pro 10.5-inch")
        
        __typePair(@"iPad8,1", @"iPad Pro 11.0-inch")
        __typePair(@"iPad8,2", @"iPad Pro 11.0-inch")
        __typePair(@"iPad8,3", @"iPad Pro 11.0-inch")
        __typePair(@"iPad8,4", @"iPad Pro 11.0-inch")
        __typePair(@"iPad8,9", @"iPad Pro 11.0-inch 2G")
        __typePair(@"iPad8,10", @"iPad Pro 11.0-inch 2G")
    
        __typePair(@"iPad6,7", @"iPad Pro 12.9-inch")
        __typePair(@"iPad6,8", @"iPad Pro 12.9-inch")
        __typePair(@"iPad7,1", @"iPad Pro 12.9-inch 2G")
        __typePair(@"iPad7,2", @"iPad Pro 12.9-inch 2G")
        __typePair(@"iPad8,5", @"iPad Pro 12.9-inch 3G")
        __typePair(@"iPad8,6", @"iPad Pro 12.9-inch 3G")
        __typePair(@"iPad8,7", @"iPad Pro 12.9-inch 3G")
        __typePair(@"iPad8,8", @"iPad Pro 12.9-inch 3G")
        __typePair(@"iPad8,11", @"iPad Pro 12.9-inch 4G")
        __typePair(@"iPad8,12", @"iPad Pro 12.9-inch 4G")
                
        return nil;
    }
    
    + (NSString *)_ipadMiniAnnounceTypeWithPreciseType:(NSString *)preciseType {
        
        __typePair(@"iPad2,5", @"iPad Mini")
        __typePair(@"iPad2,6", @"iPad Mini")
        __typePair(@"iPad2,7", @"iPad Mini")
        __typePair(@"iPad4,4", @"iPad Mini 2G")
        __typePair(@"iPad4,5", @"iPad Mini 2G")
        __typePair(@"iPad4,6", @"iPad Mini 2G")
        
        __typePair(@"iPad4,7", @"iPad mini 3G")
        __typePair(@"iPad4,8", @"iPad mini 3G")
        __typePair(@"iPad4,9", @"iPad mini 3G")
        __typePair(@"iPad5,1", @"iPad mini 4G")
        __typePair(@"iPad5,2", @"iPad mini 4G")
        __typePair(@"iPad11,1", @"iPad mini 5G")
        __typePair(@"iPad11,2", @"iPad mini 5G")
           
        return nil;
    }
    
    + (NSString *)_simulatorAnnounceTypeWithPreciseType:(NSString *)preciseType {
        
        __typePair(@"i386", @"iPhone Simulator")
        __typePair(@"x86_64", @"iPhone Simulator")
    
        return nil;
    }
    

    完~是干货吧!

    相关文章

      网友评论

          本文标题:iOS「设备标识与名称对应关系」获取函数源码(持续更新-最新更新

          本文链接:https://www.haomeiwen.com/subject/wzgauhtx.html