Chapter 10: REST for the Weary
Most iOS applications have to communicate with a remote web server in one way or another at some point. 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 are typically apps that act as a mobile client for a web service. Twitter clients, foursquare, Gowalla, 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. Caching data offline or synchronizing data with a remote server is discussed in Chapter 17.
It’s 2011, and 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 REST 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 and Dropbox. Hence, rather than explaining how to build your next Twitter client, this chapter provides some insights and best practices for designing your next iPhone app that consumes a generic, simple, and hypothetical ...