I have this class:
@interface Mission : BaseModel
{
NSString *Description;
NSDate *EndDate;
NSMutableArray *MissionSectionList;
NSString *Name;
NSDate *StartDate;
}
@property (nonatomic, retain) NSString *Description;
@property (nonatomic, retain) NSDate *EndDate;
@property (nonatomic, retain) NSMutableArray *MissionSectionList;
@property (nonatomic, retain) NSString *Name;
@property (nonatomic, retain) NSDate *StartDate;
@end
Is it possible to find out all the atrributes of this class?
I tried it with
Ivar class_getClassVariable(Class cls, const char* name)
But I don’t know what the name should be:
name: The name of the class variable definition to obtain.
And actually I want to get all of them without knowing the name.
Is this possible?
You can use
class_copyIvarListfunction to get the list of all instance variables of the class. Then you can iterate through it to get attributes of each ivar. (Note that you’re responsible for freeing memory used for ivars array). Sample code may look like: