Answer the question
In order to leave comments, you need to log in
Should I use NSTimer?
Good afternoon! I am writing a mobile application, and there you need to consider whether there is a network connection. If there is no connection, then the buttons disappear. So I solved this problem with the help of NSTimer and the Reachability class. Some code looks like this:
self.timer = NSTimer.scheduledTimerWithTimeInterval(1, target: self, selector: Selector("checkConnection"), userInfo: nil, repeats: true)
...
func checkConnection() {
if Reachability.isConnectedToNetwork() != true{
//Disable buttons here...
}
}
Am I doing the right thing? Will the timer load the system? How do you check your internet connection?
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question