-(NSString *) nibName
{
PO([self class]);
PO([super class]);
PO([self superclass]);
Only the [self superclass]
produces the actual super class.
[self class]: BGImageForBizs
[super class]: BGImageForBizs
[self superclass]: BGUIImageWithActivityIndicator
In general it is necessary. And it's often necessary for it to be the first call in your init. It first calls the init function of the parent class ( dict ). It typically creates its underlying data structure.
An Overview of Python's super() Function super() alone returns a temporary object of the superclass that then allows you to call that superclass's methods.
Sending a message using super
is the same as sending it to self
, but explicitly uses the superclass' method implementation. But your class probably doesn't implement the -class
method itself, so you're already inheriting the implementation of -class
from your superclass already.
In fact, you're probably inheriting NSObject
's implementation of -class
(even if NSObject
isn't your immediate superclass; -class
isn't a method that gets overriden often). And the default implementation just returns the contents of the object's isa
pointer, telling you what Class
it is.
In other words, it's important to recognize that calling super
doesn't completely transform your object into an instance of its superclass; it just runs the superclass' code for that method. If there's any introspection going on in that code, it still sees your object as an instance of whatever class it started out as.
self and super are the same object. The only thing super does is control which implementation of the method is called. Since both your class and the superclass are using NSObject's implementation of -class, the same method is called in both cases.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With