Given a variable id x and a string NSString *s how can I get the instance attribute with name s for variable x?
ie. If we write NSString *s=@"a", then we want x.a
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
The Objective-C Runtime Reference lists
which returns an opaque type representing an instance variable in a class. You then pass that to
to get the actual instance variable. So you could say
if the instance variable is an object. However, if the instance variable is not an object, call
passing in a pointer to a variable of the right type. For example, if the instance variable is an int,
will set
numto the value of the integer instance variable.