Skip to Content

Checking for a WiFi Connection in One Line

Posted on One min read

So if you have an app that requires a WiFi network connection in order to reliably synchronize some large-ish data set, you need to notify your user if the connection is not available. Apple provides the Reachability example app that demonstrates how to do this, and you can use the Reachablility class from that app in your own app:

  • Add the Reachability.h and Reachability.m files to your project
  • Include Reachablility.h in the header of the file you’re going to do the check
  • Add the following line:
[[Reachability reachabilityForLocalWiFi] currentReachabilityStatus] == ReachableViaWiFi