Class extension vs class category

前端 未结 4 900
没有蜡笔的小新
没有蜡笔的小新 2020-12-02 04:53

Class extensions @interface Class () are a lot more powerful and can inject variables into the class. Categories @interface Class (Category) can\

4条回答
  •  不知归路
    2020-12-02 05:27

    Categories are an Objective-C language feature that let you add new methods to an existing class. Extensions are a special case of categories that let you define methods that must be implemented in the main implementation block.

    Private declarations can be in class extensions, which mainly are some properties, because we have no need to declare a method before we call it.

提交回复
热议问题