views:

8

answers:

1

Hi Guys,

While i'm careful, there have been a few times when i have used iOS 4.x apis by mistake that have caused odd behaviour on the older devices. Is there anyway to get the compiler to flag their usage so i'm alerted when i have done so.

Many thanks as always

A: 

Unfortunately, there is no option in Xcode to warn you about an API that does not exists on your deployment target. However, there is a workaround to use the API:

Class TheClass = NSClassFromString(@"NewerClassName");
if(TheClass != nil)
{
    NewerClassName *newClass = [[NewerClassName alloc] init];
    if(newClass != nil)
    {
        //Now, you can use NewerClassName safely
    }
}

This probably won't provide warnings for that API, but it will allow you to pass Apple's validation process.

Evan Mulawski
Your solution wasn't quite what i was looking for, but you answered my question, thanks.
Jonathan