Class extension
- OBJECTIVE-C 2.0 adds the class extensions to solve two problems:
- Allows an object to have a private interface and can be validated by the compiler.
- Supports a public read-only, private writable property.
- Extension is more like an anonymous category.
Class Category
- The category is more likely to be written in a separate file, followed by the name "Nsview+customadditions.h", implemented in block blocks in the corresponding. m file. Therefore, Cagegory is more inclined to separate the functions of class, and to organize the function modules of classes.
- Extension prefers to write at the top of the. m file of the same class, and its implementation is placed in the implementation block of that class.
- such as the last Uiimage+display.h, is the system of the UIImage class supplement
Difference between Category and Class Extension?
- A category is a A-methods to add-to-existing classes. They usually reside in files called "Class+categoryname.h", like "Nsview+customadditions.h" (and. m, of course).
- A class extension is a category, except for 2 main differences:
-
- The implementation of the extension must is in the main @implementation block of the file.
- It ' s quite common to see a class extension at the top of a. m file declaring more methods on the class, that's then Impl Emented below in the main @implementation section of the class. This is a-to-declare "Pseudo-private" methods (pseudo-private in that they ' re isn't really private, just not externally Exposed).
Class-continuation category
Class-continuation category See "Effective OBJECTIVE-C 2.0" 27th
Class extension, class category, Class-continuation category