本文介绍了如何获取 iPhone 的设备名称的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
如果你打开设置->一般->关于
,它会在屏幕顶部显示Bob's iPhone.您如何以编程方式获取该名称?
If you open Settings -> General -> About
, it'll say Bob's iPhone at the top of the screen. How do you programmatically grab that name?
推荐答案
来自 UIDevice
类:
From the UIDevice
class:
Swift 版本:
UIDevice.current.name
Objective-C 版本:
[[UIDevice currentDevice] name];
UIDevice 是一个提供有关 iPhone 或 iPod 的信息触摸设备.
提供的部分信息UIDevice 是静态的,比如 device名称或系统版本.
Some of the information provided byUIDevice is static, such as devicename or system version.
来源:http://servin.com/iphone/uidevice/iPhone-UIDevice.html
官方文档: Apple 开发者文档 >UIDevice
类参考
这篇关于如何获取 iPhone 的设备名称的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!