iOS獲取設備信息與應用信息

在iOS開發過程中,有時我們想獲取到設備的系統信息,這時就需要使用到UIDevice類,具體常用信息獲取方式如下:
獲取設備唯一標識,同一個開發商的APP獲取到的標識是相同的,與UDID不同的是,在我們刪除了設備上同一個開發商的所有APP之后,下次獲取到的將是不同的標識[[UIDevice currentDevice] identifierForVendor];獲取設備系統名稱,如iPhone OS
[[UIDevice currentDevice] systemName];獲取設備系統版本,如7.1
[[UIDevice currentDevice] systemVersion];獲取設備模式,如iPhone或者iPod touch等
[[UIDevice currentDevice] model];獲取設備本地模式,返回值與model相同,暫不清楚二者區別
[[UIDevice currentDevice] localizedModel];獲取設備在'關于本機'中的名稱,如劉鵬的iPhone 6S
[[UIDevice currentDevice] name];獲取設備方向,UIDeviceOrientation是一個枚舉
/* UIDeviceOrientationUnknown, // 未知 UIDeviceOrientationPortrait, // 豎屏,home鍵在下方 UIDeviceOrientationPortraitUpsideDown, // 豎屏,home鍵在上方 UIDeviceOrientationLandscapeLeft, // 橫屏,home鍵在右方 UIDeviceOrientationLandscapeRight, // 橫屏,home鍵在左方 UIDeviceOrientationFaceUp, // 平放,屏幕朝上 UIDeviceOrientationFaceDown // 平放,屏幕朝下 */ [[UIDevice currentDevice] orientation];iOS獲取應用信息
在iOS開發過程中,有時我們想獲取到應用的信息,這時就需要使用到NSBundle類,具體常用信息獲取方式如下:
獲取應用名稱,如Test[[[NSBundle mainBundle] infoDictionary] objectForKey:@'CFBundleDisplayName'];獲取應用短版本號,如1.0(用戶看到的版本號)
[[[NSBundle mainBundle] infoDictionary] objectForKey:@'CFBundleShortVersionString'];應用Build版本號,如1.0.8(公司內部使用的版本號,在AppStore修改同一個版本的IPA文件時,可以通過自增Build版本號來實現上傳多個)
[[[NSBundle mainBundle] infoDictionary] objectForKey:@'CFBundleVersion'];獲取應用identifier,如com.liupeng.test(常用于需要同一份代碼打包成不同應用,通過判斷identifier來實現使用不同的第三方key)
[[[NSBundle mainBundle] infoDictionary] objectForKey:@'CFBundleIdentifier'];
轉載請注明出處:http://www.jianshu.com/p/d5091396e13c/,請尊重作者勞動成果。
相關文章:
1. React+umi+typeScript創建項目的過程2. ASP調用WebService轉化成JSON數據,附json.min.asp3. php測試程序運行速度和頁面執行速度的代碼4. php網絡安全中命令執行漏洞的產生及本質探究5. ASP.NET Core 5.0中的Host.CreateDefaultBuilder執行過程解析6. 無線標記語言(WML)基礎之WMLScript 基礎第1/2頁7. Warning: require(): open_basedir restriction in effect,目錄配置open_basedir報錯問題分析8. ASP中常用的22個FSO文件操作函數整理9. SharePoint Server 2019新特性介紹10. 三個不常見的 HTML5 實用新特性簡介
