One of the hardware devices available through
UIDevice is the battery. Although the user always has a battery meter in the status bar of the device, you can use access to the battery information in various ways in your app, such as not starting certain operations if the battery is really low or requiring the device to be plugged in to execute something that is likely to drain the battery significantly.
The pattern for checking the battery is instructive and is used in other situations when developing for iOS. To access the battery information, you set up an
NSNotificationCenter object, which provides a mechanism for broadcasting information within a program. In this case, you will set up a view controller to be an observer ...