views:

233

answers:

1

I'm wondering what happens when I use a MKReverseGeocoderDelegate in my ViewController, but the application is running in 2.2.1. Because I'm supporting 2.2.1 but using 3.0 as Base SDK.

I have already added the framework as soft linking to support working on 2.2.1 and I understand I have to prepare the code to check if the MKReverseGeocoder class is available to do all the fancy work with the geocoder, but I just can't understand if the delegate will crash the application on 2.2.1 because it does not exist. This is how I check if the class exists:

// Try to found location
Class geocoderClass = NSClassFromString(@"MKReverseGeocoder");
if (geocoderClass != nil)
{ // Do my stuff here 
}

But I have to declare in the header file to use the delegate for the geocodeClass. Im wondering how this works. Do i have to do anything else for preparing this code?

@interface MainViewController : UIViewController <FlipsideViewControllerDelegate, MKReverseGeocoderDelegate> {
// My declarations here
}

Thanks, Leonardo

A: 

Your code is fine. Telling that the class conforms to the protocol is the way to do it, so it compiles properly in 3.0 and it won't fail in older versions.

The methods from the delegate will simply not be called when running in 2.2.

pgb
Thanks! I think it's working fine :D
Homer1980ar