使用UiDevice获取设备信息

获取设备名称

let name = UIDevice.currentDevice().name

获取设备系统名称

let systemName = UIDevice.currentDevice().systemName

获取系统版本

let systemVersion = UIDevice.currentDevice().systemVersion

获取设备模型

let model = UIDevice.currentDevice().model

获取设备本地模型

let localizedModel = UIDevice.currentDevice().localizedModel

 

Swift获取Bundle的相关信息,我把获取的代码写到这里:

let infoDict = NSBundle.mainBundle().infoDictionary
if let info = infoDict? {
    // app名称
    let appName = info["CFBundleName"] as String!
    // app版本
    let appVersion = info["CFBundleShortVersionString"] as String!
    // app build版本
    let appBuild = info["CFBundleVersion"] as String!
}

 

如使用Object-C获取,请看另一篇文章:

IOS开发-Object-C获取手机设备信息(UIDevice)

 

 


博文作者:GarveyCalvin

博文出处:http://www.cnblogs.com/GarveyCalvin/

本文版权归作者和博客园共有,欢迎转载,但须保留此段声明,并给出原文链接,谢谢合作!

转载于:https://www.cnblogs.com/GarveyCalvin/p/4113045.html

Logo

华为开发者空间,是为全球开发者打造的专属开发空间,汇聚了华为优质开发资源及工具,致力于让每一位开发者拥有一台云主机,基于华为根生态开发、创新。

更多推荐