Objective-C 中的 super 到底是什么?
据我所知,它是指向超类的指针。它与超类是硬连接的,并且不是在运行时动态计算出来的。想更详细地了解...
有人吗?
As far as I know, it's a pointer to the superclass. It's hard-wired with the superclass, and not dynamically figured out at runtime. Would like to know it more in detail...
Anyone?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
super
本质上,它允许您使用当前类的超类的实现。
对于 坚韧 Objective-C运行时的详细信息:
[super message]
含义如下:所以是的,它是静态的,并且不是在运行时确定的。
super
Essentially, it allows you to use the implementations of the current class' superclass.
For the gritty details of the Objective-C runtime:
[super message]
has the following meaning:So yes, it is static, and not determined at runtime.
它是一个与
self
等效的关键字,但从超类的方法表开始其消息调度搜索。It's a keyword that's equivalent to
self
, but starts its message dispatch searching with the superclass's method table.super
不是指向类的指针。 Super 是 self,但当在消息表达式中使用时,它的意思是“查找从超类的方法表开始的实现”。super
is not a pointer to a class. Super isself
, but when used in a message expression, it means "look for an implementation starting with the superclass's method table."这些博客文章关于什么是元类?< /a>、获取子类 和 类和元类可能会让您了解其内部结构。
These blog postings on what is a meta class?, getting subclasses and classes and metaclasses may give you some insight on the internals of this.