美文网首页
分类中重写系统方法

分类中重写系统方法

作者: Mr_董 | 来源:发表于2016-07-01 16:31 被阅读403次

报警告

category is implementing a method which will also be implemented by its primary clase

  • 我在category中重写了原类的方法 而苹果的官方文档中明确表示 我们不应该在category中复写原类的方法,如果要重写 请使用继承 原文是这样的:A category allows you to add new methods to an existing class. If you want to reimplement a method that already exists in the class, you typically create a subclass instead of a category.

解决方法

添加这两句

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

相关文章

网友评论

      本文标题:分类中重写系统方法

      本文链接:https://www.haomeiwen.com/subject/hsafjttx.html