在Xcode中禁用特定行中的特定警告 [英] Disabling a specific warning in a specific line in Xcode

查看:98
本文介绍了在Xcode中禁用特定行中的特定警告的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在针对Base 4.0 SDK编写iPhone应用程序,但我的目标是OS 3.1.3,因此OS 3用户可以使用该应用程序。

I'm writing an iPhone app against the Base 4.0 SDK, but I'm targeting OS 3.1.3 so OS 3 users can use the app.

I call:

[[UIApplication sharedApplication] setStatusBarHidden:YES animated:YES];

在iOS 4.0中已弃用。我知道这一点,如果我们在iOS 4.0或更高版本下运行,我们会采取措施调用较新的withAnimation版本。

which is deprecated in iOS 4.0. I'm aware of this, and have measures in place to call the newer "withAnimation" version if we are running under iOS 4.0 or greater.

但是,我是收到警告我正在调用已弃用的SDK。

However, I'm getting a warning that I'm calling a deprecated SDK.

我想在这个特定的地方禁用此特定警告。我想要所有其他警告(包括其他位置的相同弃用警告)

I'd like to disable this specific warning in this specific place. I want all other warnings (including the same deprecated warning in other locations)

这可以在Xcode中完成吗?

Can this be accomplished in Xcode?

推荐答案

对于CLANG来说,这是有效的:

For CLANG, this works:

#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wdeprecated-declarations"
  // Here I like to leave a comment to my future self to explain why I need this deprecated call
  NSString *myUDID = [[UIDevice currentDevice] uniqueIdentifier];
#pragma clang diagnostic pop

你可以在一个方法中使用它,它允许你非常具体地说明导致你想要忽略的警告的那一行。

You can use it inside a method, which allows you to be very specific about the line that causes the warning you want to have ignored.

这篇关于在Xcode中禁用特定行中的特定警告的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆