分类中重写系统方法

报警告

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"

你可能感兴趣的:(分类中重写系统方法)