2012-02-20 78 views

回答

5

您可以使用valueForKey:用于此目的。

像这样:

NSString *foo = @"bar"; 

[appr.templates valueForKey: foo] 
+0

这是纯金谢谢soooooo多! – bllubbor 2012-02-20 13:23:31

4

你可以做,使用键 - 值编码或KVC,请参阅方法-valueForKeyPath:。例如:

@interface Foo 
@property(strong) NSString *bar; 
@end 

// Somewhere in other code, foo is an instance of Foo 
NSString *bar = [foo valueForKeyPath:@"bar"]; 
+0

感谢这正是需要的 – bllubbor 2012-02-20 13:24:08