Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to override deprecated warning in Xcode?

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

like image 894
ohho Avatar asked Jan 04 '11 14:01

ohho


2 Answers

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

like image 71
odyth Avatar answered Sep 28 '22 16:09

odyth


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.

like image 34
Kenneth Ballenegger Avatar answered Sep 28 '22 16:09

Kenneth Ballenegger