views:

30

answers:

1

If in a class, I have a instance variable: nsstring *foo, now I want a create a variable with a string @"foo".

exemple: I have the string @"foo", and with this string, I want a do: myobject.foo.

thx, Alex

A: 

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:

id fooValue = [myobject valueForKey:@"foo"];
[myobject setValue:barValue forKey:@"foo"];
tonklon