2012-02-20 81 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