檢測特定的iPhone/iPodtouch型號我正在制作一個游戲,利用iphone(可能還有iPodtouch第二代)的點對點藍牙功能。然而,為了阻止用戶在iPod1Gen和iPhone2G上玩多人游戲,我需要檢查特定的設備型號。[UIDevicecurrentDevice]型號]只會告訴我這款設備是“iPhone”還是“iPodtouch”。有沒有辦法檢查具體的設備型號,比如“iPhone3GS”、“iPodTouch第一代”等等。編輯:UIDevice有一個類別(我認為它是由EricaSadun創建的,我不認為它值得稱贊),它使用下面的代碼來獲得特定的設備模型。您可以在這里找到整個類別以及其他有用的內容:https://github.com/erica/uidevice-extension#include <sys/types.h>#include <sys/sysctl.h>@implementation UIDevice (Hardware)/*
Platforms
iPhone1,1 -> iPhone 1G
iPhone1,2 -> iPhone 3G
iPod1,1 -> iPod touch 1G
iPod2,1 -> iPod touch 2G
*/- (NSString *) platform{
size_t size;
sysctlbyname("hw.machine", NULL, &size, NULL, 0);
char *machine = malloc(size);
sysctlbyname("hw.machine", machine, &size, NULL, 0);
NSString *platform = [NSString stringWithCString:machine encoding:NSUTF8StringEncoding];
free(machine);
return platform;}這個工作和應用程序使用這個最近已經批準在AppStore。
檢測特定的iPhone/iPodtouch型號
慕田峪4524236
2019-10-13 12:08:22