有什么方法可以识别iPhone是否支持CDMA或GSM网络。 Objective-C 中的任何 Apple API 都可以提供此信息。
最佳答案
您可以使用函数 ( credits ) 检查模型 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;
}
函数将返回类似 @"iPhone3,3"的字符串,它代表 iPhone 4 (CDMA/Verizon)。收集各种型号的完整表格可能很困难。部分型号描述可参见 here 。当新模型出现时,您必须扩展模型表。
关于iphone - 如何检查iPhone是否支持CDMA或GSM,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7596079/