Anyone know how I can declare a static method for an xcode class and then use it in my project?
I want to create a Common.h class and then do something like this in one of .m file
Common.MyStaticMethod();
I dont want to have to instantiate and instance of Common
You will declare a class level method in Objective-C by using "+" before the method declaration.
// in Common.h + (void)myStaticMethod; // call is from anywhere [Common myStaticMethod]
That is, a "-" before method declaration means instance methods and "+" means class level method which are not related with any particular instance of the class.
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