2011-09-29 52 views

回答

5

你可能會檢查模型ID與功能(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公司)。收集各種型號的完整表格可能很困難。一些模型描述可以在here找到。隨着新模型的出現,您將不得不展開模型表格。