Category

Categories, also known as categories, are a language feature added after Objective-C2.0.

The role of the Category

1. Add new methods for the original class without modifying the original class through classification. 2. Disperse different functions into different files through classification to alleviate the problem of bloated original class code.Copy the code

Notice about categories

@property can be added to a class, but it does not generate setter/getter methods, implementation or private member variables (warning at compile time). 3, you can access the attributes in the original class. H in the classification; 4. If there is a method in the classification with the same name as the original class, the method in the classification will be called first, that is, the method in the original class will be ignored. So the precedence of method calls with the same name is category > this class > parent class. So try not to overwrite existing classes in your development; 5. If more than one class has a method with the same name as the original class, then the compiler decides which method to execute when calling the method. The compiler executes the method from the last class to be compiled.Copy the code

The underlying implementation of a Category