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

Creating the Trip Object

Finally, you have to create the Trip object. You need to make it accessible to the view controllers that need to use it, so you’ll make it an RTAppDelegate property. As you saw earlier, in Chapter 6, any object in your app can find the RTAppDelegate, and from it get a pointer to the Trip object.

Add the bolded code in Listing 11-8 to RTAppDelegate.h.

Listing 11-8: Updating the RTAppDelegate Interface

#import <UIKit/UIKit.h>

@class Trip;

@interface RTAppDelegate : UIResponder <UIApplicationDelegate>

@property (strong, nonatomic) UIWindow *window;

@property (nonatomic, strong) Trip *trip;

- (void) createDestinationModel:(int)destinationIndex;

@end

createDestinationModel: is the method that actually creates the Trip object.

@class is a compiler directive to let the compiler know that Trip is a class (or type). You need to import the header to actually use it in your code, however, and you’ll do that and synthesize the new properties by adding the bolded code in Listing 11-9 to RTAppDelegate.m.

Listing 11-9: Updating the RTAppDelegate Implementation

#import “RTAppDelegate.h”

#import “Reachability.h”

#import “Trip.h”

@implementation RTAppDelegate

@synthesize window = _window;

@synthesize trip = _trip;

You also declare a method that will actually create the Trip object. Add the bolded code in Listing 11-10 to application:didFinishLaunchingWith Options: in RTAppDelegate.m to use that method.

Listing 11-10: Updating application:didFinishLaunchingWithOptions: ...

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