Reputation: 25711
I am learning XCode and iOS for the first time. When creating an outlet with the mouse and Ctrl key, what happens to the @synthesize? In the tutorial I'm watching, it gets autocreated, but I don't see it in my Xcode. I am running the lastest OS X and latest Xcode.
If it's not autocreated, can we still overwrite the getter and setter?
Say something like this:
@synthesize topSpeed = _topSpeed;
(void)setTopSpeed:(double)speed
{
if((speed < 1) && (speed > 0) _topSpeed = speed;
}
Upvotes: 1
Views: 634
Reputation: 1022
As you have the latest OS X (!0.8) and Xcode (4.6), you do not need to explicitly specify @synthesize for each property you declare in the @interface — unless you're going to overwrite both setter and getter or if you want to use a different name as highlighted in your example of
@synthesize topSpeed = _topSpeed;
You can also overwrite the getter, and setter (if the property attribute is not readonly) as your code
(void)setTopSpeed:(double)speed
{
if((speed < 1) && (speed > 0) _topSpeed = speed;
}
shown.
Upvotes: 4