Free Trial

Safari Books Online is a digital library providing on-demand subscription access to thousands of learning resources.


  • Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • PrintPrint
Share this Page URL
Help

15. Networking > Recipe: Extending the UIDevice Class for Reachability

Recipe: Extending the UIDevice Class for Reachability

The UIDevice class provides information about the current device in use, such as its battery state, model, orientation, and so forth. Adding reachability seems like a natural extension for a class whose purpose is to report device state. Recipe 15-1 defines a UIDevice category called Reachability. It hides calls to the System Configuration framework and provides a simple way to check on the current network state. You can ask if the network is active, and whether it is using cell service or Wi-Fi.

Most connectivity-checking solutions assume that a connected device, whose connection is not provided by WWAN cell service, has Wi-Fi connectivity. This is an assumption that may not continue to hold true should Apple open up Bluetooth services to the SDK. Recipe 15-1 uses a direct Wi-Fi-checking solution developed by Matt Brown, a software developer and a fan of the first edition of this book. It has been extended slightly in this edition due to feedback from Johannes Rudolph, who figured out how to check for the new iPhone personal hotspot. It applies low-level (but SDK-friendly) calls to retrieve the local Wi-Fi IP address feature.


  

You are currently reading a PREVIEW of this book.

                                                                                                                    

Get instant access to over $1 million worth of books and videos.

  

Start a Free 10-Day Trial


  
  • Safari Books Online
  • Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • PrintPrint