有没有办法确定iPhone是否支持CDMA或GSM网络?Objective-C中任何可以提供此信息的Apple API。
发布于 2011-09-29 18:54:02
您可以使用函数(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中找到。当新的模型出现时,你必须扩展模型表。
https://stackoverflow.com/questions/7596079
复制相似问题