ivar

Why would you use an ivar?

99封情书 提交于 2019-11-26 11:30:25
I usually see this question asked the other way, such as Must every ivar be a property? (and I like bbum's answer to this Q). I use properties almost exclusively in my code. Every so often, however, I work with a contractor who has been developing on iOS for a long time and is a traditional game programmer. He writes code that declares almost no properties whatsoever and leans on ivars. I assume he does this because 1.) he's used to it since properties didn't always exist until Objective C 2.0 (Oct '07) and 2.) for the minimal performance gain of not going through a getter / setter. While he

Reason to use ivars vs properties in objective c

余生长醉 提交于 2019-11-26 06:39:36
问题 I have been unable to find any information on this topic and most of what I know about it has come by complete accident (and a few hours of trying to figure out why my code wasn\'t working). While learning objective-c most tutorials I have found make variables and properties with the same name. I don\'t understand the significance because it seems that the property does all the work and the variable just kind of sits there. For instance: Test.h @interface Test : NSObject { int _timesPlayed,