iOS 获得设备名称

//获得设备类型

std::string   getDeviceType(int  & bigVer,   int  & littleVer)

{

    /*

     * desc: get ios device type

     *

     * iPhone1,1   iPhone

     * iPhone1,2   iPhone 3G

     * iPhone2,1   iPhone 3GS

     * iPhone3,1   iPhone 4

     * iPhone3,3   iPhone 4 (Verizon)

     * iPhone3,3   iPhone 4 (CDMA)

     * iPhone4,1   iPhone 4S

     * iPhone5,1   iPhone 5 (not sure)

     *

     * iPod1,1     iPod Touch1

     * iPod2,1     iPod Touch2

     * iPod3,1     iPod Touch3

     * iPod4,1     iPod Touch4

     * iPod5,1     iPod Touch5 (not sure)

     *

     * iPad1,1     iPad1

     * iPad2,1     iPad2 (Wifi)

     * iPad2,2     iPad2 (3G GSM)

     * iPad2,3     iPad2 (3G CDMA)

     * iPad2,5     iPad Mini (may be)

     * iPad2,6     iPad Mini (may be)

     * iPad3,1     iPad3 (Wifi)

     * iPad3,2     iPad3 (4G)

     * iPad3,3     iPad3 (4G)

     * iPad3,6     iPad4 (may be)

     *  

     * i386        Simulator  

     * x86_64      Simulator 

     *  

     * AppleTV2,1 AppleTV(2G) 

     */


    struct utsname systemInfo;

    uname(&systemInfo);

    NSString *machine = [NSString stringWithCString:systemInfo.machine encoding:NSUTF8StringEncoding];

    

    std::string   strMachineName = [machine  UTF8String];

    

    string::size_type   findPos =  strMachineName.find(",");

    if (findPos !=   string::npos )

    {

        //iphone3,1

        

        string strHighVer =  strMachineName.substr(findPos -1, 1);

        bigVer = atoi(strHighVer.c_str() );

        

        

        string  strLowVer = strMachineName.substr(findPos +1,1);

        littleVer = atoi(strLowVer.c_str() );

    }

    

    

    return strMachineName;

}



  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值