How to make a real private instance variable?

后端 未结 7 818
悲&欢浪女
悲&欢浪女 2020-11-28 04:33

I want to make an instance variable that can\'t be accessed from outside. Is something like that possible in objective-c? I remember Apple has private variables and stuff li

7条回答
  •  萌比男神i
    2020-11-28 05:04

    All iVars in Objective-C are protected by default. If you don't write the accessor methods than other classes won't be able to see the variables.

    The two exceptions are categories and subclasses.

提交回复
热议问题