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 ()


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

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.