Instance variables declared in ObjC implementation file

后端 未结 3 705
没有蜡笔的小新
没有蜡笔的小新 2020-11-29 04:46

I was watching the WWDC ARC introduction video and I saw something I\'ve never seen in ObjC before when some Apple engineer talked about a Stack example.

The followi

3条回答
  •  醉梦人生
    2020-11-29 05:40

    Declaring iVars inside the implementation is definately a new construct in objective C. You need to be using xcode4.2 and have the LLVM compiler selected in your build settings. The idea is to keep your header files cleaner. You can list your ivars inside curly braces like this example;

    @implementation MyClass {    
      int var1;
      int var2;
    }
    

    The answer given by Rahul is not really correct, although you can delare variables in the way he says they would be looked upon as static by the compiler. Probably for the cases in which he used them it didnt matter.

提交回复
热议问题