开发者

How can I figure out from which class my class is inheriting?

开发者 https://www.devze.com 2023-04-02 13:00 出处:网络
I have a DamageAccount class which looks like this: @interface DamageAccount : BaseModel { NSMutableArray *DamageList;

I have a DamageAccount class which looks like this:

@interface DamageAccount : BaseModel
{
    NSMutableArray *DamageList;
    NSDate *Time;
    NSString *Title;
}

@property (nonatomic,retain开发者_StackOverflow社区) NSMutableArray *DamageList;
@property (nonatomic,retain) NSDate *Time;
@property (nonatomic,retain) NSString *Title;

@end

With [object class] I am getting the class name. But how can I figure out that this class inherits from BaseModel?

Is there any function for this?


Try isKindOfClass

Here:

  [damageAccountObject isKindOfClass:[BaseModel class]]

Will return true


[self superclass];

or

[object superclass];

Will give you the class that your object inherited from.


you can use this code of line to check the kind of the class

[objectInstant isKindOfClass:[(Your class name) class]]

put this in an if statement and it will work.

0

精彩评论

暂无评论...
验证码 换一张
取 消