Alamofire Reachability of a Host

38 Views Asked by At

I notice there is a constructor for the Alamofire.NetworkReachability class that takes a host variable. I would expect that when calling this constructor, I can use it to see if that host is reachable. Am I correct?

If I create my reachabilityManager like so:

self.reachabilityManager = Alamofire.NetworkReachabilityManager(host: "www.nonexistent.host")

and then in the same class I have a variable like this:

var isReachable: Bool {
    return self.reachabilityManager?.isReachable ?? false
}

I would expect to get 'false' when asking 'isReachable'. However, I get 'true' if I have wifi, even if that host is unreachable or nonexistent.

Am I doing something wrong?

I am using Alamofire 5.8.1

0

There are 0 best solutions below