开发者

Do I declare all the instance variables in the .h file in ObjC?

I am开发者_如何学C new to ObjC.

If I want to declare instance variables for private use of my class, do I do that in the .h file of my class inside the curly brackets?

If I just declare a variable in the body of the .m file, will it result in a global variable?

Thanks


i think you are getting confused between an instance variable and a class/global variable. An instance variable is part of every object that you create and you need to declare them within the curly braces inside the class interface. If you declare a variable in a .m file it becomes a global variable where each object does not have its own copy but instead is shared between all the objects.


Yes, you need to declare your instance variables in the .h file. You can tag them as private to make your intention more clear.


Yes, declare them in the curley brackets.

http://cocoadevcentral.com/d/learn_objectivec/

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜