Datasheet

Book VII
Chapter 1
A User Interface
for Adding Hotels
and Using the
Address Book
769
Entering and Saving the Hotel Information
id <AddHotelControllerDelegate> tells the compiler to do type check-
ing for any class assigned to this instance variable or property. The idea
here is for the compiler to check to make sure that the class has adopted the
AddHotelControllerDelegate protocol. This is one of the advantages of
using formal protocols.
You also need to add the following @synthesize statement to
AddHotelController.m.
@synthesize delegate;
Then follow up by making the changes in bold in Listing 1-16 to
HotelController.h to have it adopt the protocol.
Listing 1-16: Making Hotel Controller a Delegate
@class Trip;
@class Hotel;
#import “AddHotelController.h”
@interface HotelController : UITableViewController
<NSFetchedResultsControllerDelegate,
AddHotelControllerDelegate> {
NSFetchedResultsController *fetchedResultsController;
Trip *trip;
Hotel *hotel;
NSUndoManager *undoManager;
}
@property (nonatomic, retain)
NSFetchedResultsController *fetchedResultsController;
@property (nonatomic, retain) NSUndoManager *undoManager;
- (void)setUpUndoManager;
- (void)cleanUpUndoManager;
@end
Using default data
You might have noticed that, when I created the hotel object in insert-
NewObject, I added some default data:
[hotel setValue:@”Hotel California” forKey:@”name”];
[hotel setValue:@”1 Dr. Carlton B. Goodlett Place”
forKey:@”street”];
[hotel setValue:@”San Francisco” forKey:@”city”];
[hotel setValue:@”California” forKey:@”state”];
[hotel setValue:@”94102” forKey:@”zip”];
41_542934-bk07ch01.indd 76941_542934-bk07ch01.indd 769 3/23/10 11:01 PM3/23/10 11:01 PM