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.
精彩评论