O'Reilly logo

iPad Application Development For Dummies, 3rd Edition by Neal Goldstein

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

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 ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required