4

I am currently testing an app on an iPhone 3G with iOS 4.0.

I have the following code to check if this Class is available.

if (NSClassFromString(@"CLGeocoder"))

In the documentation it states that CLGeocoder is available for iOs 5.0 and later. But the code above does not return nil.

Why? this Class should not be available in iOS 4.0

BObereder
  • 1,046
  • 1
  • 13
  • 29
  • 3
    What does it return? `CLGeocoder` could very well have been there in iOS 4, just not publicly available. – jscs Feb 20 '12 at 18:59
  • @JoshCaswell exactly it returns CLGeocoder! Your are probably right. I already found an workaround I will post as answer as soon as I am allowed to. Thanks for your hint – BObereder Feb 20 '12 at 19:25

1 Answers1

2

To check if CLGeocoder is available and it is really running iOS 5 I used the following:

    if (NSClassFromString(@"CLGeocoder") && 
    [NSClassFromString(@"CLGeocoder") instancesRespondToSelector:
@selector(reverseGeocodeLocation:completionHandler:) ]) {

                        //iOS 5 or later    
       }
BObereder
  • 1,046
  • 1
  • 13
  • 29