Class variable defined at @implementation rather than @interface?

后端 未结 6 2070
夕颜
夕颜 2020-11-29 02:46

I\'m new to Objective-C, but I am curious about something that I haven\'t really seen addressed anywhere else.

Could anyone tell me what is the difference between a

6条回答
  •  鱼传尺愫
    2020-11-29 03:17

    If you declare a variable inside the @implementation section, you're actually creating a global variable, visible everywhere (in every method in your application).

    Member variables can only be declared in the @interface section. They are only accessible in the class itself.

提交回复
热议问题