Setting Up the Weather Controller

If the user selects Weather from the Master View in the RoadTrip application, he comes face-to-face with an Internet site displaying weather information. (You’ll start with the URL specified in the Destination.plist, but you can use any site that you’d like.)

In this section, you add the WeatherController and then add the logic it needs to get the right URL for the weather from the Trip object and send it on to the Weather (Web) view to load.

Adding the custom view controller

Although you have a view controller defined in the storyboard, it’s a generic view controller — in this case, a UIViewController — and it’s clueless about what you want to display in a view, much less the model it will need to get the data from. In this section, you create a custom controller that does know about its view and the model. So, let’s replace the generic controller with a custom one:

1. In the Project navigator, select the ViewController Classes group and then right-click and choose New File from the contextual menu that appears.

Or choose File⇒New⇒New File from the main menu (or press maccmd+N).

Whatever method you choose, the New File dialog appears.

2. In the left column of the New File dialog, select Cocoa Touch under the iOS heading, select the Objective-C class template in the top-right pane, and then click Next.

You’ll see a dialog that will enable you to ...

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.