gpt4 book ai didi

objective-c - 抑制警告 "Category is implementing a method which will also be implemented by its primary class"

转载 作者:IT老高 更新时间:2023-10-28 12:21:58 59 4
gpt4 key购买 nike

我想知道如何抑制警告:

Category is implementing a method which will also be implemented by its primary class.

我有一个特定的代码类别:

+ (UIFont *)systemFontOfSize:(CGFloat)fontSize {
return [self aCustomFontOfSize:fontSize];
}

最佳答案

尽管 bneely 所说的一切都是正确的,但它实际上并没有回答您关于如何抑制警告的问题。

如果您出于某种原因必须包含此代码(在我的项目中,我有 HockeyKit,并且它们覆盖了 UIImage 类别中的方法[编辑:不再是这种情况])并且您需要获取您的要编译的项目,您可以使用 #pragma 语句来阻止警告,如下所示:

#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wobjc-protocol-method-implementation"

// do your override

#pragma clang diagnostic pop

我在这里找到了信息:http://www.cocoabuilder.com/archive/xcode/313767-disable-warning-for-override-in-category.html

关于objective-c - 抑制警告 "Category is implementing a method which will also be implemented by its primary class",我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9424004/

59 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com