Possible Duplicate:
How does an underscore in front of a variable in a cocoa objective-c class work?
I am beginner in ios app development.I looked over many tutorial and i came across following line
.h file contains:
@property (strong) ScaryBugData *data;
.m contains:
@synthesize data = _data;
But I am not getting meaning of data = _data.
why this is required or what it means.
ref : http://www.raywenderlich.com/1797/how-to-create-a-simple-iphone-app-tutorial-part-1
_datais the name of the instance variable that is automatically created for you.datais the name of the property that has a getter and setter.If you don’t specify a custom ivar name it will just default to the name of the property.
In this case you can directly set the ivar using
_data = [ScaryBugData data], or you can use the setter usingself.data = [ScaryBugData data]. The same goes for getting.The synthesized setter will make sure the old value is properly released, the new value is properly retained and some more stuff under the hood.