Possible Duplicate:
Prefixing property names with an underscore in Objective C
When synthesizing properties I found out that someone is doing:
@synthesize myVar = _myVar;
what is “_myVar” and which is the difference with simply doing :
@synthesize myVar;
Lastly when I should prefer the first solution to the last one?
Thanks
Luca
What
_myVarreally is in your example, is the name of the ivar that is backing your property. By default, when you synthesize a property, an ivar of the same name is created for you. So, you can use your property to set your ivar through setter/getter or the_myVarto directly access your variable (bypassing KVC/KVO of course).EDIT:
From Apple’s Coding Guidelines for Cocoa