2012-02-13 71 views

回答

-1

尝试

[[UIDevice currentDevice] platformString] 

这将正常返回,如果它是iPhone 4S ...

+0

这不是标准UIDevice API的一部分:https://developer.apple.com/library/ios/#documentation/uikit/reference/UIDevice_Class/Reference/UIDevice.html – yuji 2012-02-13 16:32:24

1
#import <sys/utsname.h> 

- (NSString *)deviceModel 
{ 
    struct utsname systemInfo; 
    uname(&systemInfo); 

    return [NSString stringWithCString:systemInfo.machine encoding:NSUTF8StringEncoding]; 
} 
+0

这个函数返回给我“iPhone 4.1”,而不是“iPhone 4S”有什么理由? – user1051935 2012-02-22 18:21:29

+0

iPhone 4.1 = iPhone 4S,iPhone 3.1 = iPhone 4,iPhone 2.1 = iPhone 3GS,iPhone 1.2 = iPhone 3G和iPhone 1.1 = iPhone 1G。 – jonathananesand 2012-02-26 08:30:27