Understanding the Trip Interface

Following is what the Trip interface will eventually become:

#import <Foundation/Foundation.h>

#import <mapKit/MapKit.h>

@class Annotation;

@interface Trip : NSObject

- (UIImage *) destinationImage;

- (NSString *) destinationName;

- (CLLocationCoordinate2D) destinationCoordinate;

- (id)initWithDestinationIndex:(int)destinationIndex;

- (NSString *)weather;

- (int)numberOfEvents;

- (NSString *)getEvent:(int)index;

- (NSArray *)createAnnotations;

- (NSString *)mapTitle;

- (void)addLocation:(NSString *)findLocation

completionHandler:(void (^)(Annotation *annotation,

NSError* error)) completion;

@end

As you can see, this code contains a lot of stuff, and I explain it as you add functionality to the Trip class along the way.

Earlier in the chapter, I mention that Trip is the model interface, and I say this because in many cases more than one class will be involved in delivering the necessary functionality of the model. For example, you just added a Destination class (in this chapter) that will be responsible for the information about your destination. An Events class that you will add in Chapter 16 will be responsible for managing the list of things going on at your destination, and an Annotation class (coming in Chapter 17) will provide the information you need to plot annotations (places to see) on a map. Hiding additional model objects behind the Trip object is known as loose coupling and is an important object-oriented design principle (see ...

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.