-(void) checkBattery:(id)sender{
NSArray *stateArray=[NsArray arrayWithObjects: @"Battery state is Unknown",
@"Battery is unplugged",@"Battery is charging",@"Battery state is full",nil];
NsLog(" Battery level:%0.2f%",[[uiDevice currentDevice] batteryLevel] * 100);
NSLog("Battery state:%@",[stateArray objectAtIndex:[[UIDevice currentDevice] batteryState])
}
-(void) viewDidLoad{
[ [UIDevice currentDevice] setBatteryMonitoringEnabled:YES];
[ [ NSNotificationCenter defaultCenter ] addObserver:self selector:@selector(checkBattery)
name:UIDeviceBatteryStateDidChangeNotification
object:nil ];
[ [ NSNotificationCenter defaultCenter ] addObserver:self selector:@selector(checkBattery)
name:UIDeviceBatteryLevelDidChangeNotification
object:nil ];
}