Workaround to accomplish protected properties in Objective-C

前端 未结 4 1968
你的背包
你的背包 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:56

    If you ask for opinion, this is mine: If one decides to mutate your

    _myProtectedInt

    he will probably succed anyway, because it's definitely possible with Objective-C runtime. Except this, your solution is quite OK.

提交回复
热议问题