iosswiftuidevice

Is there an API in Swift to determine processor register size of iOS device?


I am displaying to the user whether their device is 32-bit or 64-bit. Currently, I am determining that based on the value of UInt.max:

let cpuRegisterSize = count(String(UInt.max, radix: 2))

It feels a little hacky, so I was wondering if there was an API in Swift that returns that value instead. UIDevice doesn't seem to hold that information, from what I can tell.


Solution

  • MemoryLayout<Int>.size == MemoryLayout<Int32>.size ? 32 : 64