0

我在标题中声明了一个UIImageViewASImageView是 的子类): 在我的子类中,我有一些方法,并且出于可访问性目的,我想知道变量的名称 - 在这种情况下。 有办法吗?UIImageView
@property (strong, nonatomic) IBOutlet ASImageView *imgView;
ASImageViewimgView

4

2 回答 2

0

Variables are identify by their addresses not by names. So XCode or even any plate form don't know the names of variables. Variables name are for you to identify the object as you can't identify the address.

你只能得到object. 例子:class

BOOL result = [imgView isMemberOfClass:[ASImageView class]];

isMemberOfClass:返回一个布尔值,指示接收者是否是给定类的实例。

BOOL result = [imgView isKindOfClass:[ASImageView class]];

isKindOfClass:返回一个布尔值,指示接收者是给定类的实例还是从该类继承的任何类的实例。

于 2013-08-14T11:12:52.563 回答
0

在大多数编程语言中,对象没有名称。仅仅因为某些变量imgView引用了您的对象,并不意味着您的对象被“调用” imgView

并且在大多数基于 C 的语言中,变量名根本不在最终的可执行文件中表示(外部符号的名称除外)。

所以简短的回答是没有办法获得这些信息..

于 2013-08-14T11:05:14.383 回答