NSClassFromString () returns a class, even if the class should not be accessible

I am currently testing the application on iPhone 3G with iOS 4.0.

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

if (NSClassFromString(@"CLGeocoder")) 

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

Why? this class should not be available in iOS 4.0

+4
source share
1 answer

To check if CLGeocoder is available and if iOS 5 really works, I used the following:

  if (NSClassFromString(@"CLGeocoder") && [NSClassFromString(@"CLGeocoder") instancesRespondToSelector: @selector(reverseGeocodeLocation:completionHandler:) ]) { //iOS 5 or later } 
+2
source

Source: https://habr.com/ru/post/1397481/


All Articles