Why worry about the apple clarity class and not just try to make the actual mix?

Apple provides a class called Reachability. I almost used it, but then I found that many people report problems in SO. For example, it will report false positives or cause the same error notification several times, so that the user repeatedly removes the notification that there is no Internet.

Why can't I just try to extract the data in the background and see what I get?

NSData *download = [NSData dataWithContentsOfURL:[NSURL URLWithString:urlStr]]; 

I checked: when there is no Internet, download will be just zero. Then I can call UIAlertView and complain.

Also, some users say that it’s stupid to just check the “Internet connection” because Reachability only reports the connection to the Gateway. Gateway does not have internet. My WiFi router does this all the time. The iPad has Wi-Fi reception, but not internet.

Others say it's best to check for a specific URL and see if there is a server.

So why bother with the Reachability class? Why not try the actual download, and if nothing happens, assume something is wrong?

+4
source share
2 answers

How to determine if the current active Wi-Fi network connection or transport network?

The SCNetworkReachability API allows the application to determine the status of the current network configuration of the system and the availability of the target host. One of the flags returned by the API, kSCNetworkReachabilityFlagsIsWWAN , will tell you if the network connection is connected to the target network node of the operator ...

From How-To Instructions for Network and Internet Encoding

+2
source

One of the reasons is that you check availability at startup, and if there is no Internet, you don’t even show buttons for accessing the Internet. This eliminates the need to download the entire download before you know if it is available.

In many cases, you are right. But sometimes you just want to check out long before you really download anything.

Also, if you look at Github, there are many performance improvement classes that do a better job than the one that Apple included.

+1
source

Source: https://habr.com/ru/post/1414904/


All Articles