BObereder
BObereder

Reputation: 1046

NSClassFromString() returns a class even when class should not be available

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

Upvotes: 4

Views: 715

Answers (1)

BObereder
BObereder

Reputation: 1046

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    
       }

Upvotes: 2

Related Questions