UIDevice
//裝置相關資訊的擷取 NSString *strName = [[UIDevice currentDevice] name]; NSLog(@"裝置名稱:%@", strName);//e.g. "My iPhone" NSString *strId = [[UIDevice currentDevice] uniqueIdentifier]; NSLog(@"裝置唯一標識:%@", strId);//UUID,5.0後不可用 NSString *strSysName = [[UIDevice currentDevice] systemName]; NSLog(@"系統名稱:%@", strSysName);// e.g. @"iOS" NSString *strSysVersion = [[UIDevice currentDevice] systemVersion]; NSLog(@"系統版本號碼:%@", strSysVersion);// e.g. @"4.0" NSString *strModel = [[UIDevice currentDevice] model]; NSLog(@"裝置模式:%@", strModel);// e.g. @"iPhone", @"iPod touch" NSString *strLocModel = [[UIDevice currentDevice] localizedModel]; NSLog(@"本地裝置模式:%@", strLocModel);// localized version of model
一個應用程式看上去和其他檔案沒有什麼區別. 但是實際上它是一個包含了nib檔案,編譯代碼,以及其他資源的目錄. 我們把這個目錄叫做程式的main bundle。通過這個路徑可以擷取到應用的資訊,例如應用程式名稱、版本號碼等。
//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);
NSLocale
//Getting the User’s Language NSArray *languageArray = [NSLocale preferredLanguages]; NSString *language = [languageArray objectAtIndex:0]; NSLog(@"語言:%@", language);//en NSLocale *locale = [NSLocale currentLocale]; NSString *country = [locale localeIdentifier]; NSLog(@"國家:%@", country); //en_US
@張興業TBOW