2014年4月13日日曜日

デバイスの情報を取得する

[UIDevice currentDevice]からOSバージョンやiPadかiPhoneか等、デバイスの情報を取得する。

デバイスのUDIDはかつては取得できたが、現在は取得できなくなった。

// 名称
NSLog(@"name[%@]", [UIDevice currentDevice].name);
// OS名
NSLog(@"systemName[%@]", [UIDevice currentDevice].systemName);
// OSバージョン
NSLog(@"systemVersion[%@]", [UIDevice currentDevice].systemVersion);
// デバイスのモデル
NSLog(@"model[%@]", [UIDevice currentDevice].model);
NSLog(@"localizedModel[%@]", [UIDevice currentDevice].localizedModel);
// デバイスのインターフェースタイプ(iPhoneかiPadか)
// UIUserInterfaceIdiomPhone, UIUserInterfaceIdiomPad
if ([UIDevice currentDevice].userInterfaceIdiom == UIUserInterfaceIdiomPad) {
    NSLog(@"userInterfaceIdiom is iPad");
}
else if ([UIDevice currentDevice].userInterfaceIdiom == UIUserInterfaceIdiomPhone) {
    NSLog(@"userInterfaceIdiom is iPhone");
}
// アプリのベンダー毎のUUID
NSLog(@"identifierForVendor[%@]", [UIDevice currentDevice].identifierForVendor);


2014-04-13 13:42:21.503 Device[5307:60b] name[XXXのiPad]
2014-04-13 13:42:21.505 Device[5307:60b] systemName[iPhone OS]
2014-04-13 13:42:21.506 Device[5307:60b] systemVersion[7.0.6]
2014-04-13 13:42:21.507 Device[5307:60b] model[iPad]
2014-04-13 13:42:21.509 Device[5307:60b] localizedModel[iPad]
2014-04-13 13:42:21.510 Device[5307:60b] userInterfaceIdiom is iPad
2014-04-13 13:42:21.515 Device[5307:60b] identifierForVendor[<__nsconcreteuuid 0x15604e20> D291C209-B5AF-430A-9AC5-66859F0AF1CB]


※identifierForVendorはデバイス上の対象ベンダーのアプリ全てを削除して、再インストールすると別IDになる。

0 件のコメント:

コメントを投稿