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

Finding the Location

In Listing 19-3, you assigned the text that the user entered into the Text field to a FindController property. Now you need to update the FindController interface to declare the property by adding the bolded code in Listing 19-5.

Listing 19-5: Updating the FindController Interface

#import “MapController.h”

@interface FindController : MapController

@property (strong, nonatomic) NSString *findLocation;

@end

Next, add the bolded code in Listing 19-6 to the FindController.m file to synthesize it and import the header files of the classes you’ll use.

Listing 19-6: Updating the FindController Implementation

#import “FindController.h”

#import “RTAppDelegate.h”

#import “Trip.h”

#import “Annotation.h”

@implementation FindController

@synthesize findLocation = _findLocation;

In my discussion of geocoding in Chapter 18, I point out that MapController sends the CLGeocoder the reverseGeocodeLocation: message to convert a coordinate to an address. The idea now is for you to send the geocode AddressString: message to convert an address or point of interest into a coordinate.

This time, however, you go about it in a very interesting way. When the user enters a location he or she wants to find, you want to create an annotation for that found location and display it on the map. The problem here is that you really don’t want the FindController (or any other controller) to start creating annotations — that’s the Trip model’s job.

Instead, based on the principles of encapsulation ...

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