Guest User

Untitled

a guest
Dec 11th, 2018
76
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.52 KB | None | 0 0
  1. extension UIDevice {
  2. var modelName: String {
  3. var systemInfo = utsname()
  4. uname(&systemInfo)
  5. let machineMirror = Mirror(reflecting: systemInfo.machine)
  6. let identifier = machineMirror.children.reduce("") { identifier, element in
  7. guard let value = element.value as? Int8, value != 0 else {
  8. return identifier
  9. }
  10. return identifier + String(UnicodeScalar(UInt8(value)))
  11. }
  12. return identifier
  13. }
  14. }
  15.  
  16. print(UIDevice.current.modelName)
Add Comment
Please, Sign In to add comment