开发者

Suppressing Objective-C Warnings

开发者 https://www.devze.com 2022-12-10 08:05 出处:网络
Is there any way to suppress Compil开发者_如何学Pythoner warnings ?? ThanksIf you don\'t want to see them in Xcode, you can suppress them by right-clicking on a source window and selecting Message Bu

Is there any way to suppress Compil开发者_如何学Pythoner warnings ??

Thanks


If you don't want to see them in Xcode, you can suppress them by right-clicking on a source window and selecting Message Bubbles | Errors Only. There will still be a little warning symbol next to the line, but the text of the warnings will not appear.

You can prevent the compiler from generating warnings by opening the project info window and going to the build tab. There is an Inhibit All Warnings checkbox under the GCC #.# - Warnings section. That looks like it will do what you want.

If you're building from the command line, you might try these switches:

-GCC_WARN_INHIBIT_ALL_WARNINGS -w

I've never tried those switches. They were listed in the help area in the project info window.

But the best solution, of course, is to figure out why your code has warnings and fix it.


Yes, I'm all for fixing the warnings, but what if you have an application that you want to have work on 10.4 and upwards, and in some places take advantage of methods/messages in the 10.6, but still work on 10.4?

For example, NSDate.addTimeInterval has been deprecated, so for 10.6 it's better to use NSDate.dateByAddingTimeInterval.

From what I can work out, no matter what I do, I'm going to end up with a warning on one or the other. If I add the code:

if ([NSDate instancesRespondToSelector:@selector(dateByAddingTimeInterval)]) {
  timer = [[NSTimer alloc] initWithFireDate:[nowDate dateByAddingTimeInterval:10.0] interval:0.05 target:self selector:@selector(fade:) userInfo:nil repeats:YES];
} else {
  timer = [[NSTimer alloc] initWithFireDate:[nowDate addTimeInterval:10.0] interval:0.05 target:self selector:@selector(fade:) userInfo:nil repeats:YES];
}

The I get a warning on the first half of the if statement if the sdk version is 10.5, and a warning on the second half if the sdk version is 10.6.

If I know the code is OK, is there a pragma or similar construct that will allow me to tell the compiler, that the line in question is OK?

0

精彩评论

暂无评论...
验证码 换一张
取 消