Objective-C: how to declare a static member that is visible to subclasses?

前端 未结 3 737
梦谈多话
梦谈多话 2020-12-15 04:22

I\'m declaring a family of static classes that deals with a communications protocol. I want to declare a parent class that process common messages like ACKs, inline errors..

3条回答
  •  小蘑菇
    小蘑菇 (楼主)
    2020-12-15 05:13

    A workaround would be to declare the static variable in the implementation of the parent class AND also declare a property in the parent class. Then in the accessor methods access the static variable. This way you can access static variables like properties with dot syntax. All the subclasses access the same shared static variable.

提交回复
热议问题