1.設(shè)備相關(guān)信息的獲取
NSString *strName = [[UIDevice currentDevice] name];
NSLog(@"設(shè)備名稱:%@", strName);//e.g. "My iPhone"
NSString *strId = [[UIDevice currentDevice] identifierForVendor].UUIDString;
NSLog(@"設(shè)備唯一標(biāo)識(shí):%@", strId);//UUID,5.0后不可用
NSString *strSysName = [[UIDevice currentDevice] systemName];
NSLog(@"系統(tǒng)名稱:%@", strSysName);// e.g. @"iOS"
NSString *strSysVersion = [[UIDevice currentDevice] systemVersion];
NSLog(@"系統(tǒng)版本號(hào):%@", strSysVersion);// e.g. @"4.0"
NSString *strModel = [[UIDevice currentDevice] model];
NSLog(@"設(shè)備模式:%@", strModel);// e.g. @"iPhone", @"iPod touch"
NSString *strLocModel = [[UIDevice currentDevice] localizedModel];
NSLog(@"本地設(shè)備模式:%@", strLocModel);// localized version of model
//輸出:設(shè)備相關(guān)信息的獲取
2016-08-08 17:11:45.499 宏定義的黑魔法[4576:233857] 設(shè)備唯一標(biāo)識(shí):F56E4E26-259C-4726-933D-99CF2BFB45EA
2016-08-08 17:11:45.499 宏定義的黑魔法[4576:233857] 系統(tǒng)名稱:iPhone OS
2016-08-08 17:11:45.499 宏定義的黑魔法[4576:233857] 系統(tǒng)版本號(hào):9.3
2016-08-08 17:11:45.500 宏定義的黑魔法[4576:233857] 設(shè)備模式:iPhone
2016-08-08 17:11:45.500 宏定義的黑魔法[4576:233857] 本地設(shè)備模式:iPhone
2.app應(yīng)用相關(guān)信息的獲取
NSDictionary *dicInfo = [[NSBundle mainBundle] infoDictionary];
//CFShow(dicInfo);
NSString *strAppName = [dicInfo objectForKey:@"CFBundleDisplayName"];
NSLog(@"App應(yīng)用名稱:%@", strAppName);
NSString *strAppVersion = [dicInfo objectForKey:@"CFBundleShortVersionString"];
NSLog(@"App應(yīng)用版本:%@", strAppVersion);
NSString *strAppBuild = [dicInfo objectForKey:@"CFBundleVersion"];
NSLog(@"App應(yīng)用Build版本:%@", strAppBuild);
//輸出:App應(yīng)用相關(guān)信息的獲取
2016-08-08 17:11:45.500 宏定義的黑魔法[4576:233857] App應(yīng)用名稱:(null)
2016-08-08 17:11:45.500 宏定義的黑魔法[4576:233857] App應(yīng)用版本:1.0
2016-08-08 17:11:45.500 宏定義的黑魔法[4576:233857] App應(yīng)用Build版本:1
3.獲取用戶的本地化信息設(shè)置,例如貨幣類型,國(guó)家湾蔓,語(yǔ)言腾降,數(shù)字,日期格式的格式化举哟,提供正確的地理位置顯示等等
NSArray *languageArray = [NSLocale preferredLanguages];
NSString *language = [languageArray objectAtIndex:0];
NSLog(@"語(yǔ)言:%@", language);//en
NSLocale *locale = [NSLocale currentLocale];
NSString *country = [locale localeIdentifier];
NSLog(@"國(guó)家:%@", country); //en_US
//輸出:獲取用戶的本地化信息設(shè)置
2016-08-08 17:11:45.501 宏定義的黑魔法[4576:233857] 語(yǔ)言:en-US
2016-08-08 17:11:45.501 宏定義的黑魔法[4576:233857] 國(guó)家:en_US
4.獲取系統(tǒng)版本號(hào),目的:用于判斷是否為最新版本,進(jìn)行更新提示
// 最新的版本保存到info.plist文件
NSString *curVersion = [NSBundle mainBundle].infoDictionary[@"CFBundleShortVersionString"];
// 獲取上一次保存的最新版本號(hào)
NSString *lastVersion = [[NSUserDefaults standardUserDefaults] objectForKey:@"vision"];