1. Example method/dynamic method
a). Identifier:-
b). Invocation method: (Instance object function)
c). The instance method is on the stack.
2. Static method/class method
a). Identifier: +
b). Call Mode: (class function)
c). Static methods allocate memory on the heap.
3. The distinction between static and instance methods
A). Static method resident memory, instance method is not, so the static method is high efficiency but occupies memory. In fact, the method is the same, the static method and the instance method are the same when the time is loaded and the memory is occupied, which is loaded when the type is used for the first time. The speed of the call is basically no different.
b). The static method allocates memory on the heap, and the instance method is on the stack. In fact, none of the methods can allocate memory on the heap or on the stack, as the code is loaded into a special area of code memory, which is not writable.
c). Instance methods need to create an instance before they can be called, it is cumbersome, static methods are not used, relatively simple.
d). Static methods are statically bound to subclasses, not inherited.
e). Generally use frequent methods with static methods, using less methods with dynamic. Static speed is fast, which accounts for memory. Dynamic speed is relatively slow, but after the call, the immediate release of the class, you can save memory, you can choose according to your own needs are dynamic or static methods.
f). Static methods modify the state of the class, and the object modifies the state of the individual objects.
g). An instance invocation of a class exists in the life cycle of the class, and when the class is gone, the corresponding instance is gone, and the corresponding method is gone. Static class otherwise, as long as you reference the namespace of that static class, it will persist until we launch the system.
Note: The following is the use of the class method, features: First letter capitalization, instance method is often the first letter lowercase
ios-static methods (class methods) and Instance methods