Category: Also called classification, category.
* is for class extensions without source code
* The expanded function becomes part of the original class and can be called directly from the original class or object of the original class, and can inherit
* This method can only extend the method, cannot expand the instance variable
* The added class is a pair of. h. m files, the file name is the original class name + the classification name
Extension: Extension
* Add private instance variables and methods for classes that can get the source code
* Note: The class that extends the operation is the class that can get the source code (the class with the. m file)
* The method defined by the extension is private, and the outside world is not accessible, only in the. m file of the current class.
* Equivalent to writing the category. h file in the. m file of the original class, only the. h file
Protocol: This is a way of indirect expansion of the protocol, there are only a bunch of methods of declaration, the use of the Protocol, the implementation of the method in the protocol to expand the function, but only to expand the method, can not expand the instance variable. Limited to the source code that must have the class.
Categories, extensions and agreements in OC