I have a class to check internet connection that i found here: Check for internet connection with Swift
In my methods i use it:
override func viewWillAppear(animated: Bool) {
super.viewWillAppear(animated)
if Reachability.isConnectedToNetwork() == false {
let alert = UIAlertView(title: "No Internet Connection", message: "Make sure your device is connected to the internet.", delegate: nil, cancelButtonTitle: "OK")
alert.show()
return
}
}
but can i make a decorator or something to write something like:
@check_internet_connection
override func viewWillAppear(animated: Bool) {
}
or for example use it for all methods in class:
@check_internet_connection
class MyClass: UIViewController {
...
}