Re: Silencing deprecation warnings
Re: Silencing deprecation warnings
- Subject: Re: Silencing deprecation warnings
- From: Hamish Allan <email@hidden>
- Date: Fri, 2 Apr 2010 20:56:55 +0100
result = [object performSelector:@selector(oldMethod:)
withObject:contents];
H
Please excuse the brevity -- sent from my phone
On 2 Apr 2010, at 20:37, Fritz Anderson <email@hidden> wrote:
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
_______________________________________________
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