class_getClassVariable() 的作用是什么?
我认为,如果实例变量属于类的实例,那么类变量将属于元类的实例。但我使用 Objective-C 元类的经验告诉我,这是不可能的。
我想知道 class_getClassVariable
与 class_getInstanceVariable
相比有何作用,以及为什么运行时中没有 class_setClassVariable
。
If instance variables belong to an instance of a class, class variables would belong to an instance of a metaclass, I should think. But my experience with the Objective-C metaclass tells me that this is unlikely.
I'm wondering what class_getClassVariable
does as opposed to class_getInstanceVariable
, and why there is not a class_setClassVariable
in the runtime.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我在这里找到了关于它的讨论:
http://lists.apple.com/archives/objc-语言/2008/Feb/msg00021.html
I found a discussion about it here:
http://lists.apple.com/archives/objc-language/2008/Feb/msg00021.html
class_getClassVariable() 函数没有意义,因为 Objective C 中没有类变量之类的东西。
我的猜测是运行时支持类变量,但语言不支持。
The class_getClassVariable() function doesn't make sense, because there's no such thing as a class variable in Objective C.
My guess is that class variables are supported by the runtime, but not by the language.