Possible Duplicate:
Underscore prefix on property name?
What does this mean? @synthesize window=_window; I know that in general it means that ‘some class’ has a window, but why use _window instead of just window? Is this a namespace thing?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
I’ll give a go at describing this programming convention in basic English.
It is a very common convention in other languages to name member variables with a preceding
m,m_, or_to distinguish them from locally declared variables and to signify that they should have accessors written, if necessary (noclassInstance.m_Variable = 5).If an Objective-C programmer declares ivars following this convention (and they should) and uses the basic syntax
@synthesize _window;then the usage for the property becomes somewhat ugly:classInstance._window = myWindowor[classInstance set_window:myWindow]. Using the syntax@synthesize window=_window;allows the Obj-C programmer to utilize a popular programming standard (preceding ivars with_) while simultaneously having property accessors that use the Apple standardclassInstance.window = myWindowand[classInstance setWindow:myWindow].