views:

18

answers:

1

This question...

http://stackoverflow.com/questions/3862933/check-ios-version-at-runtime

...received an answer explaining how to test if a class supports a method. (Over time, Apple may have added methods that the class, as presented in an old iOS, would not have. Rather than test for the iOS version, just test the class directly.)

Can the same thing be done for a library? I want to keep building my products for iOS 3.1.3, but I'd like to make use of CTTelephonyNetworkInfo when the users have iOS 4.0, which is the earliest iOS that supports it.

Is this possible?

A: 

The solution here is to weak link against frameworks which are only available in newer versions of iOS then use APIs like NSClassFromString and respondsToSelector: for testing if something exists before calling it. Test for capability, not firmware version.

jer