Checking for a WiFi Connection in One Line

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:

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

Next post

SSL_requirement and RSpec

If you’re using ssl_requirement, and speccing with RSpec, you’ll probably run into a problem whereby the before_filter ensure_proper_protocol redirects during your controller specs. To fix this, you can stub the call to ensure_proper_protocol, and make it return true. Add the following to your spec_helper.rb:

Read More →