In Objective-c how can we have a variable whose scope is the whole class (but doesn't include subclasses)

前端 未结 2 1814
南方客
南方客 2021-01-26 00:25

I created tons of subclasses of UITableViewCell. Each of which is a subclass of an additional BGBaseTableViewCell class.

When asked for height, I think it\'ll be useful

2条回答
  •  余生分开走
    2021-01-26 01:28

    Visible in whole class but not for subclasses? You can try this code for your .m file:

    @interface ClassYouNeed ()
    static VariableClass* variableVisibleInClassButNotInSubclass;
    @end
    

    Just make a "hidden" category on your class near your implementation, it should work.

提交回复
热议问题