1

I'm wondering is that possible to get the iOS device model number programmatically. I mean the device model on the back of iPhone. It's always in this format "AXXXX".

bourvill
  • 130
  • 1
  • 13
RayChen
  • 1,192
  • 2
  • 10
  • 31

2 Answers2

0

With a little use of private API it is possible

let device = UIDevice.current
var selector = NSSelectorFromString("deviceInfoForKey:")
if !device.responds(to: selector) {
    selector = NSSelectorFromString("_deviceInfoForKey:")
}
if device.responds(to: selector) {
    if let unmanagedModel = device.perform(selector, with:"ModelNumber") {
        let model = unmanagedModel.takeRetainedValue() as! String
        print("Device hardware model: \(model)")
    }
}
Andrey Kuznetsov
  • 813
  • 1
  • 17
  • 26
-4
let myDevice = UIDevice.currentDevice()
let deviceModel = myDevice.model
Humxaa Khan
  • 61
  • 1
  • 8