I use AFNetworking
in my app for every request (like login, get data from url, etc).
Take this for example: an user click on the login button and there's no connection, how to instantly display a UIAlertView
that says the error? The only way is to wait the request timeout and execute the failure
block? Isn't there a way that instantly check if there's connection or not?
Thanks!
As of 0.9, AFHTTPClient
actually has network reachability built-in (a simpler interface to Apple's aforementioned Reachability code). Just include the SystemConfiguration
framework and use -setReachabilityStatusChangeBlock:
to specify a response when the reachability state changes.