很多時候,我們需要獲得用戶iPhone版本號肯适,或者App的當前版本號。
關心以下兩個方面:
一框舔、App項目中伴栓,應用程序邏輯會根據(jù)iPhone硬件的版本號來進行相應的處理。版本不同,有些開發(fā)方法钳垮、環(huán)境都不同。
二额港、由于某種需求(如更新什么的)饺窿,我們需要得到我們App的當前版本。
一移斩、獲得客戶端用戶的硬件版本號
//?判斷設備的iOS?版本號
float?version = [[[UIDevice?currentDevice]?systemVersion]?floatValue];
NSLog(@"%f",version);
二肚医、我們還可以獲得更多相應的設備信息
NSLog(@"%@",[[UIDevice?currentDevice]?name]);?// 用戶為手機取的名字,如:"My Phone"
NSLog(@"%@",[[UIDevice?currentDevice]?identifierForVendor]);?// 像字符串類型的UUID向瓷,如:(iOS 6.0)
NSLog(@"%@",[[UIDevice?currentDevice]?systemName]);?// 操作系統(tǒng)名稱肠套,如:"iPhone OS"
NSLog(@"%@",[[UIDevice?currentDevice]?systemVersion]);?// 操作系統(tǒng)版本號,如:"5.1.1"
NSLog(@"%@",[[UIDevice?currentDevice]?model]);?// "My Phone" 的當前最新版本
NSLog(@"%@",[[UIDevice?currentDevice]?localizedModel]);?// "My Phone" 的本地化版本
三猖任、獲得App的版本號
//?獲得軟件的版本號,
NSDictionary* infoDict =[[NSBundle?mainBundle]?infoDictionary];//讀取?Info.plist文件的信息你稚。
float?softVerson =[[infoDict objectForKey:@"CFBundleShortVersionString"] floatValue];
這樣,版本號就獲取成功了朱躺。