Override a method in Objective c via category

后端 未结 3 1198
滥情空心
滥情空心 2020-12-08 21:21

The following is working in objective c:

// Base Class in ClassA.h and ClassA.m
@interface ClassA : NSObject 
- (NSString *) myMethod;
@end
@implementation C         


        
3条回答
  •  春和景丽
    2020-12-08 21:41

    You implicitly included the code defined in the category by compiling it.

    If you want to avoid the category code to be executed you should remove it from your target, by removing the category implementation file. You can do that from

    Target->Build Phase->Compile Sources

    That said, you should never use a category to override a method. That's a very bad practice and it's not what categories are for.

提交回复
热议问题