Class: UIDevice

NSObject show all


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.

Instance Attribute Summary (collapse)

Class Method Summary (collapse)

Instance Method Summary (collapse)

Methods inherited from NSObject

#!, #!=, #!~, #, #==, #===, #=~, #Rational, #__callee__, #__method__, #__send__, #__type__, `, alloc, allocWithZone:, #autoContentAccessingProxy, autoload, autoload?, autorelease_pool, #awakeAfterUsingCoder:, binding, block_given?, caller, cancelPreviousPerformRequestsWithTarget:, cancelPreviousPerformRequestsWithTarget:selector:object:, catch, class, classFallbacksForKeyedArchiver, #classForCoder, #classForKeyedArchiver, classForKeyedUnarchiver, #clone, conformsToProtocol:, #copy, copyWithZone:, #dealloc, #define_singleton_method, description, display, #doesNotRecognizeSelector:, #dup, #enum_for, #eql?, #equal?, #extend, fail, #finalize, format, #forwardInvocation:, #forwardingTargetForSelector:, framework, #freeze, #frozen?, getpass, gets, global_variables, #init, initialize, #initialize_clone, #initialize_copy, #initialize_dup, #inspect, instanceMethodForSelector:, instanceMethodSignatureForSelector:, #instance_eval, #instance_exec, #instance_of?, #instance_variable_defined?, #instance_variable_get, #instance_variable_set, #instance_variables, instancesRespondToSelector:, isSubclassOfClass:, #is_a?, iterator?, #kind_of?, lambda, load, load_bridge_support_file, load_plist, local_variables, loop, #method, #methodForSelector:, #methodSignatureForSelector:, #methods, #mutableCopy, mutableCopyWithZone:, new, #nil?, open, p, #performSelector:onThread:withObject:waitUntilDone:, #performSelector:onThread:withObject:waitUntilDone:modes:, #performSelector:withObject:afterDelay:, #performSelector:withObject:afterDelay:inModes:, #performSelectorInBackground:withObject:, #performSelectorOnMainThread:withObject:waitUntilDone:, #performSelectorOnMainThread:withObject:waitUntilDone:modes:, print, printf, #private_methods, proc, #protected_methods, #public_method, #public_methods, #public_send, putc, puts, raise, rand, readline, readlines, #replacementObjectForCoder:, #replacementObjectForKeyedArchiver:, require, resolveClassMethod:, resolveInstanceMethod:, #respond_to?, #respond_to_missing?, select, #send, setVersion:, #singleton_methods, sprintf, srand, superclass, #taint, #tainted?, #tap, test, throw, #to_plist, #to_s, trace_var, trap, #trust, #untaint, untrace_var, #untrust, #untrusted?, version

Constructor Details

This class inherits a constructor from NSObject

Dynamic Method Handling

This class handles dynamic methods through the method_missing method in the class NSObject

Instance Attribute Details

- (Float) batteryLevel (readonly)

The battery charge level for the device. (read-only) Battery level ranges from 0.0 (fully discharged) to 1.0 (100% charged). Before accessing this property, ensure that battery monitoring is enabled.If battery monitoring is not enabled, battery state is UIDeviceBatteryStateUnknown and the value of this property is –1.0.


- (Boolean) batteryMonitoringEnabled

A Boolean value indicating whether battery monitoring is enabled (YES) or not (NO). Enable battery monitoring if your app needs to be notified of changes to the battery state, or if you want to check the battery charge level.The default value of this property is NO, which:Disables the posting of battery-related notificationsDisables the ability to read battery charge level and battery state


  • (Boolean)

- (UIDeviceBatteryState) batteryState (readonly)

The battery state for the device. (read-only) The value for batteryState is one of the constants in “UIDeviceBatteryState.”If battery monitoring is not enabled, the value of this property is UIDeviceBatteryStateUnknown.

- (Boolean) generatesDeviceOrientationNotifications (readonly)

A Boolean value that indicates whether the receiver generates orientation notifications (YES) or not (NO). (read-only) If the value of this property is YES, the shared UIDevice object posts a UIDeviceOrientationDidChangeNotification notification when the device changes orientation. If the value is NO, it generates no orientation notifications. Device orientation notifications can only be generated between calls to the beginGeneratingDeviceOrientationNotifications and endGeneratingDeviceOrientationNotifications methods.


  • (Boolean)

- (NSUUID) identifierForVendor (readonly)

An alphanumeric string that uniquely identifies a device to the app’s vendor. (read-only) The value of this property is the same for apps that come from the same vendor running on the same device. A different value is returned for apps onthe same device that come from different vendors, and for apps on different devices regardles of vendor.


- (String) localizedModel (readonly)

The model of the device as a localized string. (read-only) This string would be a localized version of the string returned from model.


- (String) model (readonly)

The model of the device. (read-only) Possible examples of model strings are @”iPhone” and @”iPod touch”.


- (Boolean) multitaskingSupported (readonly)

A Boolean value indicating whether multitasking is supported on the current device. (read-only)


  • (Boolean)

- (String) name (readonly)

The name identifying the device. (read-only) The value of this property is an arbitrary alphanumeric string that is associated with the device as an identifier. For example, you can find the name of an iOS device in the General > About settings.


- (UIDeviceOrientation) orientation (readonly)

Returns the physical orientation of the device. (read-only) The value of the property is a constant that indicates the current orientation of the device. This value represents the physical orientation of the device and may be different from the current orientation of your application’s user interface. See “UIDeviceOrientation” for descriptions of the possible values.The value of this property always returns 0 unless orientation notifications have been enabled by calling beginGeneratingDeviceOrientationNotifications.


- (Boolean) proximityMonitoringEnabled

A Boolean value indicating whether proximity monitoring is enabled (YES) or not (NO). Enable proximity monitoring only when your application needs to be notified of changes to the proximity state. Otherwise, disable proximity monitoring. The default value is NO.Not all iOS devices have proximity sensors. To determine if proximity monitoring is available, attempt to enable it. If the value of the proximityMonitoringEnabled property remains NO, proximity monitoring is not available.


  • (Boolean)

- (Boolean) proximityState (readonly)

A Boolean value indicating whether the proximity sensor is close to the user (YES) or not (NO). (read-only)


  • (Boolean)

- (String) systemName (readonly)

The name of the operating system running on the device represented by the receiver. (read-only)


- (String) systemVersion (readonly)

The current version of the operating system. (read-only) An example of the system version is @”1.2”.


- (UIUserInterfaceIdiom) userInterfaceIdiom (readonly)

The style of interface to use on the current device. (read-only) For universal applications, you can use this property to tailor the behavior of your application for a specific type of device. For example, iPhone and iPad devices have different screen sizes, so you might want to create different views and controls based on the type of the current device.

Class Method Details

+ (UIDevice) currentDevice

Returns an object representing the current device. You access the properties of the returned UIDevice instance to obtain information about the device. You must instantiate the UIDevice instance before registering to receive device notifications.


  • (UIDevice)

    A singleton object that represents the current device.

Instance Method Details

- (Object) beginGeneratingDeviceOrientationNotifications

Begins the generation of notifications of device orientation changes. You must call this method before attempting to get orientation data from the receiver. This method enables the device’s accelerometer hardware and begins the delivery of acceleration events to the receiver. The receiver subsequently uses these events to post UIDeviceOrientationDidChangeNotification notifications when the device orientation changes and to update the orientation property. You may nest calls to this method safely, but you should always match each call with a corresponding call to the endGeneratingDeviceOrientationNotifications method.


- (Object) endGeneratingDeviceOrientationNotifications

Ends the generation of notifications of device orientation changes. This method stops the posting of UIDeviceOrientationDidChangeNotification notifications and notifies the system that it can power down the accelerometer hardware if it is not in use elsewhere. You call this method after a previous call to the beginGeneratingDeviceOrientationNotifications method.


- (Object) playInputClick

Plays an input click in an enabled input view. Use this method to play the standard system keyboard click in response to a user tapping in a custom input or keyboard accessory view. A click plays only if the user has enabled keyboard clicks in Settings > Sounds, and only if the input view is itself enabled and visible.To enable a custom input or accessory view for input clicks, perform the following two steps:Adopt the UIInputViewAudioFeedback protocol in your input view class.Implement the enableInputClicksWhenVisible delegate method to return YES.For more information, see Text, Web, and Editing Programming Guide for iOS.