I have been trying several methods but none have worked.
I've been trying to use some of the codes to get battery level in Xcode5 but none have worked. I required the reading to change every time the level of the battery updates.
class ViewController: UIViewController {
@IBOutlet weak var level_Battery: UILabel!
override func viewDidLoad() {
super.viewDidLoad()
UIDevice.current.isBatteryMonitoringEnabled = true
let level = UIDevice.current.batteryLevel
let battery_Level = Int(level * 100)
level_Battery.text = "\(battery_Level)%"
}
}
I expect that the text variable always shows an updated battery level reading. so whatever the phone battery level charge is I would like to show that inside of the app.