ios - objective-c : how to inherit category methods loaded in a parent class?
<p><p>在我的项目中,我使用的是 <code>NSObject+Properties.h</code> 类别(参见 aqtoolkit:<a href="https://github.com/AlanQuatermain/aqtoolkit/blob/master/Extensions/NSObject%2BProperties.h" rel="noreferrer noopener nofollow">https://github.com/AlanQuatermain/aqtoolkit/blob/master/Extensions/NSObject%2BProperties.h</a>)</p>
<p>然后我有一个我声明为的类</p>
<pre><code>#import <Foundation/Foundation.h>
#import "NSObject+Properties.h"
@interface GFDictionaryInitiable : NSObject
...
</code></pre>
<p>然后我有几个<code>GFDictionaryInitiable</code>的子类,比如<code>GFResaurant</code>:</p>
<pre><code>#import <Foundation/Foundation.h>
#import "GFDictionaryInitiable.h"
@interface GFRestaurant : GFDictionaryInitiable
...
</code></pre>
<p>我的问题是我无法访问子类中 <code>NSObject+Properties</code> 类别中定义的方法。例如我得到错误:</p>
<pre><code>-: unrecognized selector sent to instance 0x2e57240
</code></pre>
<p>如何让我的所有子类“继承”父类中加载的类别方法?</p></p>
<br><hr><h1><strong>Best Answer-推荐答案</ strong></h1><br>
<p><p>当您收到 <em>运行时异常</em>,而不是编译器错误时,我假设您忘记了
将“NSObject+Properties.m”添加到您的目标。选择文件并检查
文件检查器中的“目标成员”复选框。</p></p>
<p style="font-size: 20px;">关于ios -objective-c: how to inherit category methods loaded in a parent class?,我们在Stack Overflow上找到一个类似的问题:
<a href="https://stackoverflow.com/questions/19432324/" rel="noreferrer noopener nofollow" style="color: red;">
https://stackoverflow.com/questions/19432324/
</a>
</p>
页:
[1]