如何检查iPhone是否支持CDMA或GSM

san*_*ndy 2 iphone gsm cellular-network cdma ios4

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

Val*_*Van 5

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

#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;
    }
Run Code Online (Sandbox Code Playgroud)

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