如何抑制“可用性与先前声明不匹配"警告 [英] How to suppress "Availability does not match previous declaration" warning

查看:37
本文介绍了如何抑制“可用性与先前声明不匹配"警告的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我必须使用一些私有函数,例如:

I have to use some private functions, like:

SCDynamicStoreRef
SCDynamicStoreCreate            (
                    CFAllocatorRef          allocator,
                    CFStringRef         name,
                    SCDynamicStoreCallBack      callout,
                    SCDynamicStoreContext       *context
                    )               __OSX_AVAILABLE_STARTING(__MAC_10_1,__IPHONE_NA);

默认情况下,它们不允许用于 iphone,所以我在我的 .m 文件中更改了它们的声明.但现在它显示可用性与之前的声明不匹配"警告.如何抑制此警告?

By default they are not allowed for iphone, so I've changed declaration of them in my .m file. But now it shows "Availability does not match previous declaration" warning. How to suppress this warning?

推荐答案

通常的免责声明是使用私有 API 可能会导致您的应用被拒绝:您可以使用

With the usual disclaimer that using private APIs might cause your app to be rejected: You can suppress the warning with

#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wavailability"
…
#pragma clang diagnostic pop

如果 iOS 中存在该功能,它也可能导致崩溃或其他故障框架,但具有不同的参数.

It might also cause crashes or other failures if that function is present in the iOS frameworks, but with different parameters.

这篇关于如何抑制“可用性与先前声明不匹配"警告的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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