Samhan Salahuddin
Samhan Salahuddin

Reputation: 2170

Calling class method from instance method in objective c

What is the safe and correct way of calling a class method from an instance method in objective - C ?

Upvotes: 0

Views: 154

Answers (2)

Grijesh Chauhan
Grijesh Chauhan

Reputation: 58261

you can do like:

- (void)your_instanceMethodB
{

    [[self class] your_classMethodA];

}  

READ this: Call a class method from within that class . Jon Reid and others answers.

Upvotes: 2

Ismael
Ismael

Reputation: 3937

If you are using subclasses and your subclass overrides the method, then you should do

 [[self class] myFunction];

If not, the standard way is correct

[MyClass myFunction];

Upvotes: 1

Related Questions