Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

Jeremy1026

macrumors 68020
Original poster
Nov 3, 2007
2,215
1,029
I am trying to return the battery level of the device. But, no matter what my battery is, it returns 1.0. Here is my code that I am using.


Code:
UIDevice *myDevice = [UIDevice currentDevice];

[myDevice setBatteryMonitoringEnabled:YES];
float batLeft = [myDevice batteryLevel]; 

NSLog(@"%f",batLeft);
 
Solved: This code does work. I just wasn't letting my battery drain enough. It only updates every 5% (from what I can tell.)
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.