1, Category- category1> Basic uses
Classification : You can extend some methods to a class ( without modifying the original code )
How to extend some methods to the class without changing the original class model?
There are 2 ways: inheritance ; classification (CATEGOTY).
2> format
Declaration of classification
@interface class names (category name)
//Method declaration
@end
Declaration of classification
@implementation class names (category name)
//method declaration
@end
3> Category Creation method in Xcode 7.2
New File -- objective-c file --file is the category name, thefile type is selectedcategory, class is the classes to create the classification
Category names are typically named by module name
4> Benefits
When a class is particularly large and has different functions , we can write a function in a category that is more conducive to team development.
5> Use note
- Categories can only increment methods and cannot increase member variables
- member variables in the original class can be accessed in the classification method implementation
- Classification can re-implement the methods in the original class, but will overwrite the original method, will cause the original method can not be used
- Classification is the highest priority, method invocation, priority to the classification of the search, and then go to the original class to find, and finally go to the parent class to find
- If the same method is implemented in multiple category, only the last one that participates in the compilation will be valid
- View Compilation order: Click Project name, build phases, compiles Sources
Video iOS 09 unique syntax