Since when is it possible to declare Objective-C 2.0 properties in a category?

后端 未结 3 1664
醉梦人生
醉梦人生 2021-02-05 13:52

I always thought that one cannot declare an object property in a category. Until my partner did it in our app\'s code, and it seemed to work.

I went on a SO and Google b

3条回答
  •  花落未央
    2021-02-05 14:48

    Generally speaking, properties are nothing different from other methods. As long as the ivar used is available in the ordinary class, there is no problem at all. It's just syntactic sugar.

    Things start to get more difficult if also the ivar is automatically created, as is possible in some configurations.

    The main point here is that declaration of the ivar is independent from the property.

提交回复
热议问题