Chapter 14: REST for the Weary
At some point, most iOS applications have to communicate with a remote web server in one way or another. Some apps can run and be useful without a network connection, and web server communication might be short-lived (or even optional) for the application. Apps that fall into this category are those that sync data with a remote server when a connection is present, such as to-do lists.
Another set of apps needs nearly continuous network connectivity to provide any meaningful value to the user. These apps typically act as a mobile client for a web service. Twitter clients, foursquare, Facebook, and most apps you write fall into this category. This chapter presents some techniques for writing apps the right way for consuming a web service. We discuss caching data offline or synchronizing data with a remote server in Chapter 24.
As of this writing, a quick search for Twitter in Apple’s App Store turns up nearly 650 iPad apps and more than 3,000 iPhone apps. Today, if you want to create the next Twitter client, you don’t have to know anything about web services or the Twitter API. There are more than a dozen implementations of the Twitter API in Objective-C. The same is true for most public services like Facebook’s Graph API or Dropbox. So, rather than explaining how to build your next Twitter client, this chapter provides insights and best practices for designing your next iPhone app that consumes a generic, simple, and hypothetical web service.