I have AFNetworking setup to monitor the network reachability status, so that when it becomes available I can immediately make a REST call that would have failed while it wasn't.
I've found that it isn't telling me of status changes, however. I'm simulating a 100% loss on my Mac, and during those times, calls to the REST API would fail, but AFNetworking would have its reachability status as availableViewWWAN
. Then when I turn off the 100% loss, the REST calls work again, but the status according to AFNetworking hasn't changed.
This is the code I'm using with it right now:
import AFNetworking
class ConnectionManager {
static let sharedManager = ConnectionManager()
init() {
AFNetworkReachabilityManager.sharedManager().startMonitoring()
AFNetworkReachabilityManager.sharedManager().setReachabilityStatusChangeBlock() {
(status: AFNetworkReachabilityStatus) -> Void in
print("reachability status changed: \(status.rawValue)")
}
}
}
This is because a 100% loss situation isn't equal to doesn't have a connection at all. 100% loss means that all of the packets are dropped but the network connection still exists, it is usefull when you want to simulate a timeout connection.
In order to simulate the no network case you should turn your wifi connection off on your mac or iDevice, for simulator or physical device.