How to make a real private instance variable?

后端 未结 7 844
悲&欢浪女
悲&欢浪女 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条回答
  •  一个人的身影
    2020-11-28 05:13

    The Apple docs for naming instance variables doesn't explicit warn against using underscore in the name of instance variables like the private method documents do.

    Naming Instance Variables and Data Types

    I also remember a conversation between Wil Shipley and a few other OS X developers concern the underscores. Because of the way the Obj-C compiler works, if Apple were to add a new instance variable to a class in their frameworks, it would cause all apps using those frameworks to need to be recompiled. As far as pre-existing instance variables, you should get a warning when you step on one.

提交回复
热议问题