Workaround to accomplish protected properties in Objective-C

前端 未结 4 1994
你的背包
你的背包 2021-01-30 04:35

I\'ve been trying to find a workaround to declare @protected properties in Objective-C so only subclasses in the hierarchy can access them (read only, not write). I read that th

4条回答
  •  轮回少年
    2021-01-30 04:51

    Sure, that works fine. Apple uses the same approach for example in the UIGestureRecognizer class. Subclasses have to import the additional UIGestureRecognizerSubclass.h file and override the methods that are declared in that file.

提交回复
热议问题