The UIDevice class provides a Singleton instance representing the current device. From this instance you can obtain information about the device such as assigned name, device model, and operating-system name and version.


You also use the UIDevice instance to detect changes in the device’s characteristics, such as physical orientation. You get the current orientation using the orientation property or receive change notifications by registering for the UIDeviceOrientationDidChange notification. Before using either of these techniques to get orientation data, you must enable data delivery using the beginGeneratingDeviceOrientationNotifications() method. When you no longer need to track the device orientation, call the endGeneratingDeviceOrientationNotifications() method to disable the delivery of notifications.

Similarly, you can use the UIDevice instance to obtain information and notifications about changes to the battery’s charge state (described by the batteryState property) and charge level (described by the batteryLevel property). The UIDevice instance also provides access to the proximity sensor state (described by the proximityState property). The proximity sensor detects whether the user is holding the device close to their face. Enable battery monitoring or proximity sensing only when you need it.

Starting in iOS 4.2, you can use the playInputClick() instance method to play keyboard input clicks in custom input and keyboard accessory views.


Getting the Shared Device Instance

class var current: UIDevice

Returns an object representing the current device.

Determining the Available Features

var isMultitaskingSupported: Bool

A Boolean value indicating whether multitasking is supported on the current device.

Identifying the Device and Operating System

var name: String

The name identifying the device.

var systemName: String

The name of the operating system running on the device represented by the receiver.

var systemVersion: String

The current version of the operating system.

var model: String

The model of the device.

var localizedModel: String

The model of the device as a localized string.

var userInterfaceIdiom: UIUserInterfaceIdiom

The style of interface to use on the current device.

var identifierForVendor: UUID?

An alphanumeric string that uniquely identifies a device to the app’s vendor.

Getting the Device Orientation

var orientation: UIDeviceOrientation

Returns the physical orientation of the device.

var isGeneratingDeviceOrientationNotifications: Bool

A Boolean value that indicates whether the receiver generates orientation notifications (true) or not (false).

func beginGeneratingDeviceOrientationNotifications()

Begins the generation of notifications of device orientation changes.

func endGeneratingDeviceOrientationNotifications()

Ends the generation of notifications of device orientation changes.

Getting the Device Battery State

var batteryLevel: Float

The battery charge level for the device.

var isBatteryMonitoringEnabled: Bool

A Boolean value indicating whether battery monitoring is enabled (true) or not (false).

var batteryState: UIDeviceBatteryState

The battery state for the device.

Using the Proximity Sensor

var isProximityMonitoringEnabled: Bool

A Boolean value indicating whether proximity monitoring is enabled (true) or not (false).

var proximityState: Bool

A Boolean value indicating whether the proximity sensor is close to the user (true) or not (false).

Playing Input Clicks

func playInputClick()

Plays an input click in an enabled input view.



The type of interface that should be used on the current device


All UIDevice notifications are posted by the singleton device instance returned by current.

static let UIDeviceOrientationDidChange: NSNotification.Name

Posted when the orientation of the device changes.

static let UIDeviceProximityStateDidChange: NSNotification.Name

Posted when the state of the proximity sensor changes.

Type Properties

class var current: UIDevice

Returns an object representing the current device.


Inherits From

Conforms To