Show the device

To show what kind of device the user have, you can add this code to a swift file

import UIKit

@MainActor
final class DeviceController: ObservableObject {
    @Published private(set) var iDevice: String
    
    init() {
        self.iDevice = UIDevice.current.localizedModel
    }
}

In the view you can now add

@StateObject var deviceType = DeviceController()

The deviceType.iDevice will show “iPhone”, “iPad” or “iPod” etc. as String

Leave a Reply

Your email address will not be published. Required fields are marked *