「ios開発」デバイスとアプリに関する情報を取得サンプル

サンプルコード:

//デバイスに関する情報
NSString *strName = [[UIDevice currentDevice] name];
NSLog(@”デバイス名:%@”, strName);
NSString *strId = [[UIDevice currentDevice] uniqueIdentifier];

NSString *strSysName = [[UIDevice currentDevice] systemName];
NSLog(@”システム名:%@”, strSysName);// e.g. @”iOS”
NSString *strSysVersion = [[UIDevice currentDevice] systemVersion];
NSLog(@”システムバージョン:%@”, strSysVersion);// e.g. @”6.0″
NSString *strModel = [[UIDevice currentDevice] model];
NSLog(@”デバイスモード:%@”, strModel);// e.g. @”iPhone”, @”iPod touch”
NSString *strLocModel = [[UIDevice currentDevice] localizedModel];
NSLog(@”ローカルデバイスモード:%@”, strLocModel);// localized version of model

//appに関する情報
NSDictionary *dicInfo = [[NSBundle mainBundle] infoDictionary];

// CFShow(dicInfo);
NSString *strAppName = [dicInfo objectForKey:@”CFBundleDisplayName”];
NSLog(@”App名:%@”, strAppName);
NSString *strAppVersion = [dicInfo objectForKey:@”CFBundleShortVersionString”];
NSLog(@”Appバージョン:%@”, strAppVersion);
NSString *strAppBuild = [dicInfo objectForKey:@”CFBundleVersion”];
NSLog(@”AppのBuildバージョン:%@”, strAppBuild);

//ユーザーの言語を取得する
NSArray *languageArray = [NSLocale preferredLanguages];
NSString *language = [languageArray objectAtIndex:0];
NSLog(@”言語:%@”, language);//en
NSLocale *locale = [NSLocale currentLocale];
NSString *country = [locale localeIdentifier];
NSLog(@”国:%@”, country); //en_US

//画面サイズ
CGRect rect = [[UIScreen mainScreen] bounds];
CGSize size = rect.size;
CGFloat width = size.width;
CGFloat height = size.height;
NSLog(@”幅、高:%f,%f”,width,height);

//解像度
CGFloat scale_screen = [UIScreen mainScreen].scale;
NSLog(@”screen w:%f”,width*scale_screen);
NSLog(@”screen h:%f”,height*scale_screen);

Comments are closed.