September 21, 2012
Good Friday #4: SKReachability
Sorry I haven’t had any Good Fridays in the last 3 weeks. I hope Kanye’s GOOD Friday from two weeks ago was able to tide you over. I’m at SecondConf for the weekend, so this week’s update is gonna be smaller.
SKReachability is a singleton that gives quick access to information about the connection.
Usage is simple. Call
[SKReachability sharedReachability] to initialize the singleton. Set the
host property to test connection to a specific host. It defaults to the Google homepage.
Subscribe to notifications for reachability changes:
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(reachabilityChanged:) name:kSKReachabilityChangedNotification object:nil];
and then you can access the properties
connectedToHostwhen the notification is fired. You can also access them at any point to determine the state of the network.
SKReachability uses Apple’s Reachability, so make sure you have that, and
Find it on Github: github.com/khanlou/SKReachability