How to get the iphone model

0

I'm starting with swift and I need to get the exact IPHONE template from the client, I already tried UIDevice returns Iphone or Ipad and I need to know if the device is an SE, 7, 8+, X, etc. Does anyone know how to do it?

    
asked by anonymous 02.01.2018 / 18:43

1 answer

1

Opa came to take a look at this answer? link

This function seems to return what you need

    func modelIdentifier() -> String {
    if let simulatorModelIdentifier = ProcessInfo().environment["SIMULATOR_MODEL_IDENTIFIER"] { return simulatorModelIdentifier }
    var sysinfo = utsname()
    uname(&sysinfo) // ignore return value
    return String(bytes: Data(bytes: &sysinfo.machine, count: Int(_SYS_NAMELEN)), encoding: .ascii)!.trimmingCharacters(in: .controlCharacters)
}
    
17.01.2018 / 20:02