I created a function which checks whether the iPhone is charging or not using UIDevice
. Where should I call the function so that it monitors the status throughout the app session? The Function is called "connectivityStatus", at present it's in viewWillAppear
.
Language : Swift 3
Platform : iOS 10 (Using UIDevice)
Hari please define a function in Appdelegate.h and give the defination of the function in Appdelegate.m . Now you can use this function through the app like this [[Appdelegate appdelegate] "Name of your function"]. I hope this will help. Paste the below code in Appdelegate.m inorder to use appdelegate .
+(AppDelegate*)appDelegate
{
return (AppDelegate*)[UIApplication sharedApplication].delegate;
}
swift
class func appDelegate() -> AppDelegate {
return (UIApplication.sharedApplication().delegate as! AppDelegate)
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With