如何检查iPhone是否支持CDMA或GSM [英] How to check if iPhone supports CDMA or GSM

查看:239
本文介绍了如何检查iPhone是否支持CDMA或GSM的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有没有办法确定iPhone是否支持CDMA或GSM网络。 Objective-C中的任何Apple API都可以提供此信息。

Is there any way to identify if iPhone supports CDMA or GSM network. Any Apple API in Objective-C which can provide this information.

推荐答案

您可以使用该函数检查模型ID(的):

You might examine model id with the function (credits):

#include <sys/types.h>
#include <sys/sysctl.h>
NSString* machine () {
        size_t size;

            // Set 'oldp' parameter to NULL to get the size of the data
            // returned so we can allocate appropriate amount of space
        sysctlbyname("hw.machine", NULL, &size, NULL, 0); 

            // Allocate the space to store name
        char *name = malloc(size);

            // Get the platform name
        sysctlbyname("hw.machine", name, &size, NULL, 0);

            // Place name into a string
        NSString *machineid = [NSString stringWithUTF8String:name];

            // Done with this
        free(name);

        return machineid;
    }

函数将返回类似@iPhone3,3的字符串,代表iPhone 4 (CDMA / Verizon公司)。可能很难收集各种型号的完整表格。可以在此处找到一些模型描述。当新模型出现时,您必须扩展模型表。

Function will return string like @"iPhone3,3" which stands for iPhone 4 (CDMA/Verizon). It might be difficult to gather full table of various model numbers. Some of the models descriptions could be found here. You'll have to expand table of models as new models will appear.

这篇关于如何检查iPhone是否支持CDMA或GSM的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆