0

On obj-c, when will i declare a private variable in header file. like below @interface Contact : NSObject{ NSString *name; NSUInteger age; }

define a private variable, it can't be access by any instance. why there is need to do it. i think this scene is no need to exist.

now, i want to know which scene will use such way to declare variable, the advantage use this way.

maple
  • 101
  • 1
  • 13
  • Inside .m file you can declare. – if-else-switch Jun 28 '14 at 09:22
  • Thanks quickly reply. yeah, i know .m file i can declare, but on .h file also can declare. when will i declare on .h file – maple Jun 28 '14 at 09:24
  • 1
    Please go through the basic objective-c books or better to search through this site. There are many answers given to your question. The requirement is all dependent on your programming logic. When there is a use of protected kind of members then we use to declare in .h – if-else-switch Jun 28 '14 at 09:26
  • that is lots of possible duplicate answer. User must do some RND and please read that duplicate answer ther is 7 answer with lots of link. – Nitin Gohel Jun 28 '14 at 09:33

0 Answers0