我有以下代码。
我得到的输出是:
@implementation UIDevice(machine)
- (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 *machine = [NSString stringWithCString:name];
// Done with this
free(name);
return machine;
}
@end
/* ... */
NSLog(@"device: %@", [[UIDevice currentDevice] machine]);
我得到的输出是:
Platforms:
-----------
iPhone1,1
iPhone1,2
iPod1,1
iPod2,1
iPhone/iPod Touch后面附加的两个数字代表什么意思,比如(1,1),(1,2)等?
谢谢, Biranchi
NSString+stringWithCString
е·Іиў«ејғз”ЁпјҢжӮЁеә”иҜҘдҪҝз”ЁNSString+stringWithCString:encoding
гҖӮ - zekel