我想做的是将类别的方法分为私有方法和公共方法。私有方法需要在该类别的文件之外可见,而不是在类之外。
例如,假设我有以下文件:
ClassA.m
ClassA.h // <-- Includes definitions of public category methods
ClassAPrivates.h // <-- Includes definition of private category methods.
ClassA+Render.m
ClassAPrivates.h
看起来像这样:
@interface ClassA()
// private methods here, for use inside ClassA
@end
@interface ClassA(Render)
// the private methods of the Render category.
-(void)privateConfigureDeviceContext;
-(void)privateConfigureBufferSpace;
@end
'ClassA.h' 看起来像这样:
@interface ClassA : NSObject
// public methods of ClassA
@end
@interface ClassA (Render)
// public methods of category Render
-(void)drawLine;
-(void)drawCircle;
@end
但是,XCode 抱怨 Render 的重复接口。任何解决方法?