0

Is their anyway to add decoration to properties in objective-c, that can be discovered during run-time using reflection? I would like to define the following class

@interface ABC{}

@property (nonatomic, copy) NSString * s1;
@property (nonatomic, copy) NSString * s2;
@property (nonatomic, copy) NSString * s3;

I would like to add some kind of attribute for the properties s1 and s2, so I can discover these properties during run-time and perform some operation, which is not applicable to s3. So something like

[Run-Time_Discover] @property (nonatomic, copy) NSString * s1;

I know that Tnterface builder, uses IBOutlet for discovering properties. Can I discover properties defined by some such macro during run-time?

4

1 回答 1

0

你可以检查一个对象是否实现了一个方法(记住,属性只是方法),如下所示:

[theObject respondsToSelector:@selector(s3)];

这里不需要注释。

于 2013-03-15T02:16:42.290 回答