Possible Duplicate:
Objective C Introspection/Reflection
I am looking for the way to get the object’s members type name in sequence declared in the object header.
such as, if I get an object like this
@interface Person : NSObject {
int age;
NSString *name;
PersonDetail *detail;
}
When I get the data like {28,@"Jack",{@"basketball",@"Male",@"Master Degree"}} in array.
I would need the type of members to fill the data in.
It’s like in java where there is a function like getField() to get the members in order.
So is there any methods I can use?
Thank.
Have a look at the Objective-C Runtime Reference. It includes functions for doing things like getting a class’s ivar list (
class_copyIvarList()), or get an objects actual ivars (object_getIndexedIvars()) and things like that. It should be able to do something like what you want.