I used NSLog(@"%@",super) in a method(any method) and it is crashing.... Why? How to print the super contents?
Updated :
currentclassname : superClassName
{
}
and also if i use NSLog(@"%@", [super description]); It is printing "<currentclassname: 0x3db7230>" instead of superClassName... It is expected to print superClassName right.
Thanks in advance,
When encountering the keyword super and a method call on it, the compiler generates a different call - objc_msgSendSuper*() instead of the usual objc_msgSend*().
objc_msgSendSuper*() calls get an argument of type objc_super* instead of objc_object*:
struct objc_super {
id receiver;
Class class;
};
So, objc_super* values aren't special instances, they have to be used with the special objc_msgSendSuper*() functions.
Thus, as Alex says, just call -description directly on super - its value is meaningless outside of the context its in unless you specifically use it with a runtime function like objc_msgSendSuper().
Use -description, e.g.:
NSLog(@"%@", [super description]);
If you have access to the superclass, you can override its -description method to return whatever information you want, or perhaps augment the class with a category.
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