Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What exactly is super in Objective-C?

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?

like image 718
dontWatchMyProfile Avatar asked Jun 22 '10 17:06

dontWatchMyProfile


1 Answers

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:

When it encounters a method call, the compiler generates a call to one of the functions objc_msgSend, objc_msgSend_stret, objc_msgSendSuper, or objc_msgSendSuper_stret. Messages sent to an object’s superclass (using the super keyword) are sent using objc_msgSendSuper; other messages are sent using objc_msgSend. Methods that have data structures as return values are sent using objc_msgSendSuper_stret and objc_msgSend_stret.

So yes, it is static, and not determined at runtime.

like image 51
Ben S Avatar answered Oct 01 '22 01:10

Ben S