【问题标题】:how to hide objective-c delegate method comments out of header file如何从头文件中隐藏objective-c委托方法注释
【发布时间】:2017-05-24 03:35:24
【问题描述】:

目前我正在开发一个库,有一些委托方法需要注释,但我不希望它出现在头文件中,因为它可能被其他人更改,它太多了头文件。我怎样才能做到这一点? this is cocoa touch delegate method

this is where it is declared

【问题讨论】:

    标签: objective-c cocoa-touch comments header-files


    【解决方案1】:

    您可以使用类别来做到这一点。创建一个分隔头文件(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"
    

    【讨论】:

      猜你喜欢
      • 2016-11-10
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多