If in a class, I have a instance variable: nsstring *foo, now I want a create a variable with a string @”foo”.
Example: I have the string @”foo”, and with this string, I want a do: myobject.foo.
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.
I think what you are looking for is KVC Key-Value Coding.
It enables you to retrieve or set a property or an instance variable on an object by it’s name (a String). You can do something like: