Question: How to call superclass static method ?
I mean directly by using:
[SuperClassName method]
OR
There is any other way existed?
A static method is the one which you can call without instantiating the class. If you want to call a static method of the superclass, you can call it directly using the class name.
We can declare static methods with the same signature in the subclass, but it is not considered overriding as there won't be any run-time polymorphism. Hence the answer is 'No'.
From Wikipedia: Static methods neither require an instance of the class nor can they implicitly access the data (or this, self, Me, etc.) of such an instance. This describes exactly what Objective-C's class methods are not.
Overriding is when we pass a child class object to a parent class reference variable but the static methods are associated with class they are not linked with an object so we can't override a static method but we can hide a static method in java.
If you wants to call drive class methods from base class then, declare class method in your drive class like this: using (+) sign before method name.
+(void)myClassMethod;
Call this method from base class like this:
[YourDriveClassName myClassMethod];
Or you wants to call drive class instance methods from base class, declare instance method in your drive class using (-)sign before method name.
-(void)sayHelloToSomeOne:(NSString *)greeting;
Call this method from base class.
[super sayHelloToSomeOne:@"Hello Worlds!"];
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