How does an underscore in front of a variable in a cocoa objective-c class work? -
I have seen in some iPhone examples, which use an underscore _ in front of the attributes variable. Know what this means? Or how does this work?
An interface file that I am using:
@interface MissionCell: UITableViewCell {mission * _mission; UILBL * _missionName; } @ Property (Nonomatic, Rectangle) UILABL * Mission Name; - Mission (mission); I'm not sure what the above version does, but when I try to set the mission name:
aMission.missionName = MissionName; I get an error:
request for member 'missionName' is not in some structure or union
If you use the underscore prefix for your eyeware (which is nothing more than a common convention but useful) So you have to do 1 extra thing so that the auto-generated accessor (for the property) knows which ivar is to use, in particular, your implementation file In your synthesized in should look like this:
or @ synthesis missionName = _missionName; More generally, this is:
@ synthesis property name = _ivarName;
Comments
Post a Comment