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
@interface FindController : MapController
@property (strong, nonatomic) NSString *findLocation;
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
@synthesize findLocation = _findLocation;
In my discussion of geocoding in Chapter 18, I point out that
MapController sends 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 ...