Initializing the Destination Class

Now it’s time to turn to the Destination class and its initialization. Add the bolded code in Listing 11-4 to Destination.h to update its interface to add the header files, the properties you’ll be using, and the method declarations.

Listing 11-4: Updating the Destination Interface

#import <Foundation/Foundation.h>

#import <mapKit/MapKit.h>

@interface Destination : NSObject <MKAnnotation>

@property (nonatomic, readwrite)

CLLocationCoordinate2D coordinate;

@property (nonatomic, readwrite, copy) NSString *title;

@property (nonatomic, readwrite, copy) NSString *subtitle;

@property (nonatomic, strong) NSString *destinationName;

@property (nonatomic, strong) UIImage *destinationImage;

- (id)initWithDestinationIndex:

(NSUInteger)destinationIndex;

@end

As you saw in Chapter 4, you’ll be displaying the destination on a map with an annotation (that pop-up window that displays information about the location when you touch the pin on the map). Doing that requires that the class adopt the MKAnnotation protocol, which requires a coordinate property of type CLLocationCoordinate2d (that’s why you need to include the MapKit and CoreLocation frameworks) and optional title and subtitle properties. Although you won’t be doing anything with this part of Destination until Chapter 17, I have you initialize Destination with what is described in the plist but defer the explanation until Chapter 17.

Next you need to add the synthesize statements for the ...

Get iPad Application Development For Dummies, 3rd Edition 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.