【发布时间】:2017-05-24 03:35:24
【问题描述】:
目前我正在开发一个库,有一些委托方法需要注释,但我不希望它出现在头文件中,因为它可能被其他人更改,它太多了头文件。我怎样才能做到这一点? this is cocoa touch delegate method
【问题讨论】:
标签: objective-c cocoa-touch comments header-files
目前我正在开发一个库,有一些委托方法需要注释,但我不希望它出现在头文件中,因为它可能被其他人更改,它太多了头文件。我怎样才能做到这一点? this is cocoa touch delegate method
【问题讨论】:
标签: objective-c cocoa-touch comments header-files
您可以使用类别来做到这一点。创建一个分隔头文件(Private Header),其中包含*_Internal.h 之类的任何后期修复。并在那里定义所有私有方法/委托。
示例
Hello.h
@interface Hello : NSObject
- (void)publicMethod;
@end
Hello_Internal.h
@interface Hello (Internal)
- (void)privateMethod;
@end
Hello.m
@implementation Hello
- (void)privateMethod {
}
- (void)publicMethod {
}
@end
在库中使用
#import "Hello.h"
#import "Hello_Internal.h"
【讨论】: