When I was studying OC, I always had no idea when to use the class method, when I used the instance method. So I made the following summary.
-Represents an instance method: Access by instance method
+ Represents a class method: An object of a class method when the class is not an instance. More for creating objects or tool classes
When to use a class method, to create an instance to get a shared instance, or to get some common information about the class.
1. The class method belongs to the entire class, not to an object.
2. Class methods can access only class member variables, cannot access instance variables, and instance methods access class member variables and instance variables.
3. The invocation of a class method can be done through the class name. class methods and objects. Class methods, and instance methods can only be accessed through the object. Instance method.
4. Class methods can only access class methods, and instance methods have access to class methods and instance methods.
5, the class method cannot be overwritten, the instance method can be overwritten.
The difference and connection between Object-c and instance methods