Xcode will auto synthesise an iVar as if you had written...
@synthesize name = _name;
This means you can access the property with...
self.name;// or _name;
Either will work but only self.name actually uses the accessor methods.
There is only one time that auto synthesise does not work.
If you overwrite but the setter AND the getter method then you will need to synthesise the iVar.
You are fine if you just override the setter or if you just override the getter. But if you do both then the compiler won't understand it and you will need to synthesise it manually.
As a rule of thumb though.
Don't make iVars. Just use the property. Don't synthesise it.
Liked By
Write Answer
Why do we need to use @Synthesize?
Join MindStick Community
You have need login or register for voting of answers or question.
Tarun Kumar
14-Jul-2015when you create a property...
Xcode will auto synthesise an iVar as if you had written...
This means you can access the property with...
Either will work but only
self.name
actually uses the accessor methods.There is only one time that auto synthesise does not work.
If you overwrite but the setter AND the getter method then you will need to synthesise the iVar.
You are fine if you just override the setter or if you just override the getter. But if you do both then the compiler won't understand it and you will need to synthesise it manually.
As a rule of thumb though.
Don't make iVars. Just use the property. Don't synthesise it.