Code Snippet: How to Track Battery Life Remaining

Jan 24, 2013
This weeks code snippet is a common question for new iPhone developers: A way to track the battery percentage!
// Calculates Battery Life
UIDevice *device = [UIDevice currentDevice];
device.batteryMonitoringEnabled = YES;
int batteryLevel = [device batteryLevel] * 100; // Battery Level is given as a value between 0.0 and 1.0

No comments:

Post a Comment