iOS獲取設(shè)備信息與應(yīng)用信息

在iOS開發(fā)過程中,有時(shí)我們想獲取到設(shè)備的系統(tǒng)信息,這時(shí)就需要使用到UIDevice類,具體常用信息獲取方式如下:
獲取設(shè)備唯一標(biāo)識(shí),同一個(gè)開發(fā)商的APP獲取到的標(biāo)識(shí)是相同的,與UDID不同的是,在我們刪除了設(shè)備上同一個(gè)開發(fā)商的所有APP之后,下次獲取到的將是不同的標(biāo)識(shí)[[UIDevice currentDevice] identifierForVendor];獲取設(shè)備系統(tǒng)名稱,如iPhone OS
[[UIDevice currentDevice] systemName];獲取設(shè)備系統(tǒng)版本,如7.1
[[UIDevice currentDevice] systemVersion];獲取設(shè)備模式,如iPhone或者iPod touch等
[[UIDevice currentDevice] model];獲取設(shè)備本地模式,返回值與model相同,暫不清楚二者區(qū)別
[[UIDevice currentDevice] localizedModel];獲取設(shè)備在'關(guān)于本機(jī)'中的名稱,如劉鵬的iPhone 6S
[[UIDevice currentDevice] name];獲取設(shè)備方向,UIDeviceOrientation是一個(gè)枚舉
/* UIDeviceOrientationUnknown, // 未知 UIDeviceOrientationPortrait, // 豎屏,home鍵在下方 UIDeviceOrientationPortraitUpsideDown, // 豎屏,home鍵在上方 UIDeviceOrientationLandscapeLeft, // 橫屏,home鍵在右方 UIDeviceOrientationLandscapeRight, // 橫屏,home鍵在左方 UIDeviceOrientationFaceUp, // 平放,屏幕朝上 UIDeviceOrientationFaceDown // 平放,屏幕朝下 */ [[UIDevice currentDevice] orientation];iOS獲取應(yīng)用信息
在iOS開發(fā)過程中,有時(shí)我們想獲取到應(yīng)用的信息,這時(shí)就需要使用到NSBundle類,具體常用信息獲取方式如下:
獲取應(yīng)用名稱,如Test[[[NSBundle mainBundle] infoDictionary] objectForKey:@'CFBundleDisplayName'];獲取應(yīng)用短版本號(hào),如1.0(用戶看到的版本號(hào))
[[[NSBundle mainBundle] infoDictionary] objectForKey:@'CFBundleShortVersionString'];應(yīng)用Build版本號(hào),如1.0.8(公司內(nèi)部使用的版本號(hào),在AppStore修改同一個(gè)版本的IPA文件時(shí),可以通過自增Build版本號(hào)來實(shí)現(xiàn)上傳多個(gè))
[[[NSBundle mainBundle] infoDictionary] objectForKey:@'CFBundleVersion'];獲取應(yīng)用identifier,如com.liupeng.test(常用于需要同一份代碼打包成不同應(yīng)用,通過判斷identifier來實(shí)現(xiàn)使用不同的第三方key)
[[[NSBundle mainBundle] infoDictionary] objectForKey:@'CFBundleIdentifier'];
轉(zhuǎn)載請(qǐng)注明出處:http://www.jianshu.com/p/d5091396e13c/,請(qǐng)尊重作者勞動(dòng)成果。
相關(guān)文章:
1. 以PHP代碼為實(shí)例詳解RabbitMQ消息隊(duì)列中間件的6種模式2. html小技巧之td,div標(biāo)簽里內(nèi)容不換行3. PHP字符串前后字符或空格刪除方法介紹4. 將properties文件的配置設(shè)置為整個(gè)Web應(yīng)用的全局變量實(shí)現(xiàn)方法5. nestjs實(shí)現(xiàn)圖形校驗(yàn)和單點(diǎn)登錄的示例代碼6. AspNetCore&MassTransit Courier實(shí)現(xiàn)分布式事務(wù)的詳細(xì)過程7. XML入門的常見問題(一)8. jsp cookie+session實(shí)現(xiàn)簡(jiǎn)易自動(dòng)登錄9. css進(jìn)階學(xué)習(xí) 選擇符10. Echarts通過dataset數(shù)據(jù)集實(shí)現(xiàn)創(chuàng)建單軸散點(diǎn)圖
