Reputation: 8066
I have a NSObject
@interface MyObject : NSObject
@property bool pName1;
@property NSString *pName2;
I hope to detect the name(pName1,pName2..) of properties in the function
-(void)dosomething:(id)a
Is it possible? Welcome any comment
Upvotes: 0
Views: 71
Reputation: 124997
You can get a list of the properties for a given class using the runtime function class_copyPropertyList()
. There's also a runtime function property_getName()
that will give you the name for a given property. Using these two functions, you can get the names of all the properties for a given object.
Upvotes: 2