Static method (which isn't class method) in objective C Static method (which isn't class method) in objective C objective-c objective-c

Static method (which isn't class method) in objective C


The problem you are having is the following - there are no static methods in Obj-C, that's why you cannot create them.

The difference between static and class methods is a difference between language concepts. You can find static methods in languages like Java or C++, you will find class methods in languages like Obj-C and Ruby.

The principal difference is that

  1. Static methods are shared between all instances (this doesn't exist in Obj-C). They are dispatched statically (at compile time) depending on the type of the variable.

  2. Class method is a method on a class. In languages like Obj-C and Ruby a class itself is an instance of another class (metaclass). Using + before a method declaration means the method will be defined on the class. Technically, it's just an instance method, just on a different object.

Don't worry if you don't understand the concept of class method perfectly, it takes time. To simplify, you can consider it as a method shared between instances, but it can be overriden in subclasses.