Computer >> Hướng Dẫn Máy Tính >  >> Lập Trình >> iOS

Lấy UDID, tên, phiên bản, model thiết bị iOS theo chương trình

Sử dụng UIDevice.current trong viewDidLoad:

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 ?? "")   // ví dụ: D774EAE3F447445F9D5FE2B3B699ADB1
  print(name)         // ví dụ: iPhone XR
  print(version)      // ví dụ: 12.1
  print(modelName)    // ví dụ: iPhone
}