在我的項目,我使用的NSObject+Properties.h
類別(見aqtoolkit:https://github.com/AlanQuatermain/aqtoolkit/blob/master/Extensions/NSObject%2BProperties.h)Objective C:如何繼承在父類中加載的類別方法?
然後我有一個類,我宣佈爲
#import <Foundation/Foundation.h>
#import "NSObject+Properties.h"
@interface GFDictionaryInitiable : NSObject
...
我那麼有GFDictionaryInitiable
幾個子類,如GFRestaurant
:
#import <Foundation/Foundation.h>
#import "GFDictionaryInitiable.h"
@interface GFRestaurant : GFDictionaryInitiable
...
我的問題是,我不能訪問我的子類NSObject+Properties
類中定義的方法。例如,我得到的錯誤:
-[GFRestaurant hasPropertyNamed:]: unrecognized selector sent to instance 0x2e57240
我怎麼能有我所有的子類「繼承」了在父類加載的類的方法?
你確定「NSObject + Properties.m」已被添加到你的目標? –
它應該工作。你確定你的.m文件包含在你的目標中嗎?轉到'Build Phases> Compiled Sources'並查看'NSObject + Properties.m'是否存在。 –