Wiley iPhone Application Development All-In-One For Dummies 978-0-470-54293-4 ユーザーズマニュアル

製品コード
978-0-470-54293-4
ページ / 46
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
A
lthough 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
New from the main menu (or press Ô+N) to get the New 
File window.
 2. 
In the left column of the dialog, select Cocoa Touch Classes under the 
iPhone OS heading, select the UIViewController subclass template 
in the top-right pane and then click Next.
41_542934-bk07ch01.indd   741
41_542934-bk07ch01.indd   741
3/23/10   11:01 PM
3/23/10   11:01 PM
COPYRIGHTED MATERIAL