It is generally believed that it is better to avoid polling and instead request notifications from the system, for example:
[[UIDevice currentDevice] setBatteryMonitoringEnabled:YES]; [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(batteryLevelUpdate) name:UIDeviceBatteryLevelDidChangeNotification object:nil];
... where batteryLevelUpdate will look like this:
- (void)batteryLevelUpdate:(NSNotification *)notification {
From the Link to the UIDevice class :
Notifications about changes in battery level are sent no more than once per minute. Do not try to calculate the drainage rate of the battery or the remaining battery life; drainage speed can often change depending on the built-in applications, as well as on your application.
Once a minute, 10 times more often than your code currently checks with less CPU time. It is not mentioned, however, what degree of detail of the changes will lead to notifications - is this a change of 0.01% for sending or is a change of 1% required?
To answer another question, if you have to set setBatteryMonitoringEnabled back to NO : if you use notifications, rather than manually polling for the setBatteryMonitoringEnabled battery, then the answer is that you should leave it in YES or the risk of Missing notifications.
Apple's official BatteryStatus sample uses the same battery status report.
There is also a UIDeviceBatteryStateDidChangeNotification that will notify you when the device is discharged (in use), charged or fully charged.
source share