(1)無法向類中添加新的實例變量。
(2)名稱沖突,即當類別中的方法與原始類方法名稱沖突時,類別具有更高的優先級。
(3)如果多個分類中都有和原有類中同名的方法, 那么調用該方法的時候執行誰由編譯器決定;編譯器會執行最后一個參與編譯的分類中的方法
struct category_t { const char *name; classref_t cls; struct method_list_t *instanceMethods; // 對象方法 struct method_list_t *classMethods; // 類方法 struct protocol_list_t *protocols; // 協議 struct property_list_t *instanceProperties; // 屬性 // Fields below this point are not always present on disk. struct property_list_t *_classProperties;
method_list_t *methodsForMeta(bool isMeta) { if (isMeta) return classMethods; else return instanceMethods; }
property_list_t *propertiesForMeta(bool isMeta, struct header_info *hi); }; |
2)類(cls)
3)category中所有給類添加的實例方法的列表(instanceMethods)
4)category中所有添加的類方法的列表(classMethods)
5)category實現的所有協議的列表(protocols)
6)category中添加的所有屬性(instanceProperties)