Hi am developing a app using swift2.2 in my app i want to check internet connection so i followed a method http://www.brianjcoleman.com/tutorial-check-for-internet-connection-in-swift/. It works well now i also want to check for slow internet process, because when the internet is very slow my app leads to crash.I don't know to deal with it i have checked many stack flow answers nothing helped can some one help me to deal with this process....
Asked
Active
Viewed 2,331 times
1
-
1You would probably have better results by fixing whatever thing is causing the crash. (Also, what does the title of the question have to do with your problem?) – Phillip Mills Mar 14 '17 at 13:13
-
sorry i forgot to change the title – user7333282 Mar 14 '17 at 13:32
-
Have you get my question?? when internet connection is good it works well but when i have bad internet connection i loads sometimes later it leads to crash – user7333282 Mar 14 '17 at 13:37
-
1I understand. My suggestion is to fix the crash rather than trying to detect internet speed. – Phillip Mills Mar 14 '17 at 13:42
-
We can't help you diagnose a crash without more information. What does the crash log look like? What does the crashing code look like? – Caleb Mar 14 '17 at 13:44
1 Answers
0
If you want to check whether there is internet connection before calling the webservice you can use the third party library called Reachability and
If there is no internet do whatever you want like a loading icon or something
Objective C
Reachability *reachability = [Reachability reachabilityForInternetConnection];
NetworkStatus internetStatus = [reachability currentReachabilityStatus];
if (internetStatus != NotReachable) {
//webservice implementation
}
else {
//no internet connection
}
Swift
class func hasConnectivity() -> Bool {
let reachability: Reachability = Reachability.reachabilityForInternetConnection()
let networkStatus: Int = reachability.currentReachabilityStatus().rawValue
return networkStatus != 0
}

Saranjith
- 11,242
- 5
- 69
- 122
-
will this help when internet is connected and bad network connection – user7333282 Mar 14 '17 at 12:07
-
-
its an inbuild library in ios. You can use it to know the network speed also.. follow the url http://stackoverflow.com/a/14584397/5215474 – Saranjith Mar 14 '17 at 12:19