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

The Weather Controller

Now that you have the Trip object set up to deliver the data you need, the WeatherController needs to pass on to the view to load the web page.

You need to add some #import compiler directives so that Weather Controller can access RTAppDelegate to get the Trip reference and request the data it needs.

To do that, add the bolded code in Listing 15-3 to WeatherController.m.

Listing 15-3: Updating the WeatherController Implementation

#import “RTDetailViewController.h”

#import “RTAppDelegate.h”

#import “Trip.h”

@interface WeatherController ()

@end

@implementation WeatherController

The template provides a viewDidLoad method stub when you create the controller file. You may recall from previous chapters that this is where you want to have the Web view (or any other view) load its data. Add the bolded code in Listing 15-4.

Listing 15-4: Adding to ViewDidLoad

- (void)viewDidLoad

{

[super viewDidLoad];

self.title = @”Weather”;

self.weatherView.scalesPageToFit = YES;

RTAppDelegate *appDelegate =

[[UIApplication sharedApplication] delegate];

[self.weatherView loadRequest:

[NSURLRequest requestWithURL:[NSURL

URLWithString:[appDelegate.trip weather]]]];

}

The first thing you do in Listing 15-4 is set the title to Weather.

The title won’t be showing up on the toolbar, however, since this just sets the title in the Navigation bar. I’ll use it when I add a Return To Whatever button in the “Managing links in a Web view” section, a bit later in the chapter. ...

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