Is there a way to call a class method from another method within the same class?
For example:
+classMethodA{
}
+classMethodB{
//I would like to call classMethodA here
}
Is there a way to call a class method from another method within the same class?
For example:
+classMethodA{
}
+classMethodB{
//I would like to call classMethodA here
}
Sure.
Say you have these methods defined:
The first 2 class methods could be implemented as follows:
In a class method,
self
refers to the class being messaged. So from within another class method (say classMethodB), use:From within an instance method (say instanceMethodB), use:
Note that neither presumes which class you are messaging. The actual class may be a subclass.
Should be as simple as:
If that's not working, make sure you have the method signature defined in the class's interface. (Usually in a .h file)
In objective C 'self' is used to call other methods within the same class.
So you just need to write