O'Reilly logo

Learning Mobile App Development: A Hands-on Guide to Building Apps with iOS and Android by Michael Eierman, Jakob Iversen

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Monitoring Battery Status

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 ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required