Question

Detail : I am ready to submit an update to my app to Apple. However, I have one area of doubt. I have added the following code in the header of one of my classes ...

#import <CoreTelephony/CTTelephonyNetworkInfo.h>

and this in the main class ...

if ([CTTelephonyNetworkInfo class]) {
    //Now do some telephony stuff ...

Telephony is for iOS 4 and above. I believe that anyone still on iOS3 should be fine because of the if statement, but I can't test it because I dont have an old device and XCode 4.2 doesn't have an old emulator.

My iOS Deployment target is still 3.0, and I'd preferably like to keep it that way to ensure everyone can use my app.

Question : Is my code correct? Is my iOS Deployment Target correct? Am I going about this in the correct way?

Was it helpful?

Solution

The code is correct (As @SimonH points out, you used to need a NSClassFromString, but that changed with some version of the compiler, by the time the 4.0 SDK was released).

You also need to make sure you weak link CoreTelephony (or for that matter any framework not available on 3.x), so the binary won't attempt to load it when launching the app.

OTHER TIPS

No it's not.

if (NSClassFromString(@"CTTelephonyNetworkInfo") != nil)
{
    // use class
}
else
{
    // not available, deal with it.
}

Is what you should use. Using what you wrote the app will just crash as it wont find CTTelephonyNetworkInfo class. Also you should make sure that you've set the CorTele... framework as optional.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top