ใช้ UIDevice.current ดึงข้อมูลอุปกรณ์:
- UDID/UUID:
identifierForVendor?.uuidString(ไม่ใช่ UDID จริง แต่ unique ต่อ vendor) - Name:
name(เช่น "iPhone XR") - iOS Version:
systemVersion(เช่น "12.1") - Model:
model(เช่น "iPhone", "iPad")
โค้ดตัวอย่าง
override func viewDidLoad() {
super.viewDidLoad()
let udid = UIDevice.current.identifierForVendor?.uuidString
let name = UIDevice.current.name
let version = UIDevice.current.systemVersion
let modelName = UIDevice.current.model
print(udid ?? "") // D774EAE3F447445F9D5FE2B3B699ADB1
print(name) // iPhone XR
print(version) // 12.1
print(modelName) // iPhone
}
ผลลัพธ์
แสดงข้อมูลอุปกรณ์ใน console
รูปภาพตัวอย่าง UI ถูกละเว้น