The dynamic characteristics of object-c allow the use of categories to add new methods to existing classes, and do not need to create subclasses, without accessing the source code of the original class. By using categories, you can dynamically add new methods to existing classes, and you can modularize the class definition into multiple related files.
Point:1, the definition class name must be a class that is not in the project, and the class name that is used when defining a category must be an existing class 2, defining a category must use () to contain the class name 3, the category is typically defined only by the classes method and the instance method, cannot add an instance variable (can be added by extension extension) 4, Do not overload another method, resulting in the original method is not available 5, according to the need can have more than one classification, classification will affect subclass 6, through the class for the specified class to add a new method, the new method can affect the subclass of the specified class, subclass can also inherit to this new method. 7. Use categories to invoke Private method 8, use categories to implement informal protocol 9, you can use categories to modular design of classes
@interface existing class (category name)-instance method + class method @end
Extended @interface already has class () {instance variable;}-class method; + instance method; @end
Category "Object-c" and extension categories