I have one question about the variables of an object, I would like to know if I can check if a string is an object’s instance variable or not?
Below, an example to illustrate my issue :
I have an object – MyObject.h :
@interface MyObject : NSObject
{
//Variables
id myVariable1;
id myVariable2;
}
@property (nonatomic, retain) id myVariable1;
@property (nonatomic, retain) id myVariable2;
And I have also an array list:
NSArray * myArray = [[NSArray alloc] initWithObjects:@"myVariable1",@"myVariable2",@"myVariable3",@"myVariable4",nil];
I would like to know if it’s possible to determinate which strings in the array list aren’t defined as variable in the object MyObject.
=> myVariable3 and myVariable4 for this case.
I tried to use “isKindOfClass”, “isMemberOfClass”, “valueForKeyPath”, “valueForKey” but without success… Let me know if you have some advices to resolve my problem 🙂
Assuming the properties aren’t using a custom setter name, you could do: