Chapter 1. A User Interface for Adding Hotels and Using the Address Book

In This Chapter

  • Creating a user interface to add a hotel

  • Accessing the Address Book to use exiting information

  • Adding a hotel address to the Address Book

Although the ability to add hotels that you want to stay in is obviously important (staying in the hard-coded default hotel San Francisco is a bit awkward if you're in Needles, California, for example), it's also really helpful to integrate your Address Book with your application to avoid the annoying "double" entry.

In this chapter, I show you how to create a view that allows the user to both enter a hotel as well as add that hotel to his or her Address Book. I also show you how to take a hotel already in the Address Book and add it as a hotel in the RoadTrip application.

Being able to do that becomes even more important when you realize that, even though the title of the view says "Hotels," a hotel can really be any place you're planning to stay. This includes the couch at your best friend's former girl- or boyfriend's cousin's.

Add AddHotelController

As you might expect, the first thing you need to do is add a view controller to manage the data entry view, like so:

  1. In the RoadTrip project window, select the Classes folder and then choose File

    Add AddHotelController
  2. In the left column of the dialog, select Cocoa Touch Classes under the iPhone OS heading, select the UIViewController subclass ...

Get iPhone® Application Development All-In-One For Dummies® now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.