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.
Markdown for AI
A clean, structured version of this page for AI assistants and LLMs.
We use cookies to ensure you have the best browsing experience on our website. By using our site, you
acknowledge that you have read and understood our
Cookie Policy &
Privacy Policy.
when 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.nameactually 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.