Silencing deprecation warnings
Silencing deprecation warnings
- Subject: Silencing deprecation warnings
- From: Fritz Anderson <email@hidden>
- Date: Fri, 2 Apr 2010 14:37:04 -0500
I've advanced my project to a new SDK. The old SDK had a method, oldMethod:, that the new SDK deprecates in favor of newMethod:. Okay, so I do the Right Thing:
float result = 0.0;
if ([object respondsToSelector: @selector(newMethod:)])
result = [object newMethod: contents];
else
result = [object oldMethod: contents];
The compiler warns that oldMethod: is deprecated. True. I believe in keeping my builds warning-free. How do I suppress this warning, as narrowly as possible? That is, I'd like to exempt just this one call from the warning; failing that, I'd like to suppress it for the file.
The gcc flag -Wno-deprecated had previously been suggested. I selected the file in the Compile Sources phase of my target, and put the option into the Build tab. Compiling produces this warning:
cc1obj: warning: command line option "-Wno-deprecated" is valid for C++/ObjC++ but not for ObjC
And the warning appears again. So -Wno-deprecated is not the answer. The compiler version is GCC 4.2.
Another proposed solution is to declare a protocol (call it DeprecatedMethods) that includes the deprecated selector, and do this:
result = [ (id<DeprecatedMethods>) object oldMethod: contents];
I imagine it works, but it's horrible.
Is there a good way to do this?
— F
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Xcode-users mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden