15
What is an actual name of instance variable, say, topSpeed, as from lectures of Stanford University about the Objective-C and iOS development?
Here is the code:
@property (nonatomic) double topSpeed;
Looking at this code I will think that I have defined a variable topSpeed in the class. I can't understand why it will declare automatically the getter method with the name the same as the variable name - topSpeed?
Another question is when we use
@synthesize topSpeed = _topSpeed
And if we look at what the @synthesize will generate:
- (double) setTopSpeed:(double)speed
{
_topSpeed = speed;
}
- (double) topSpeed
{
return _topSpeed;
}
What is _topSpeed here and what is topSpeed? I have declared a variable topSpeed, not the _topSpeed. What if I don't use property what would the variable name be?