5

Is there a #pragma to override a compile time warning, e.g.:

warning: 'ADBannerContentSizeIdentifier480x32' is deprecated (declared at /Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS4.2.sdk/System/Library/Frameworks/iAd.framework/Headers/ADBannerView.h:111)

I have to keep compatibility for pre-4.2 iOS devices by:

NSString *iAdSize = (osVersion >= 4.2) ? ADBannerContentSizeIdentifierPortrait : ADBannerContentSizeIdentifier480x32;

Thanks

ohho
  • 50,879
  • 75
  • 256
  • 383

3 Answers3

8

Yes there is

#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wno-deprecated-declarations"
//deprecated function
#pragma clang diagnostic pop

If you ever wonder what the proper syntax is for a certain error just find it in Xcode then look at the quick help

enter image description here

odyth
  • 4,324
  • 3
  • 37
  • 45
2

There's a build setting to toggle warning for deprecated functions.

Though the right way to do this would be check for OS version at runtime, and execute the deprecated method if necessary, or the new one otherwise.

Kenneth Ballenegger
  • 2,970
  • 2
  • 19
  • 25
0

You can suppress a specific deprecated warning by creating a 'Deprecated.h' file, in which you declare the deprecated methods as good in a category.

Kenneth Ballenegger
  • 2,970
  • 2
  • 19
  • 25
  • 2
    this is a bad idea, you should instead just suppress the specific warning using the pragma syntax – odyth Sep 13 '13 at 01:11