Properties - setWeightInKilos variable no longer in Person.m


I’m going throughout the section on Properties (don’t have a page number since I’m reading this off the Kindle app; for reference it’s location 2129 of 5839 on my computer).

I’ve modified the code accordingly in Person.h and Person.m. So instead of the more cumbersone getters and setters, I’m using the @property construct in Person.h and @synthesize in Person.m.

There are no problems with the Build & Run, my only issue is that I don’t understand how we are declaring instance variables in main.m which no longer seem to be declared elsewhere. For instance:

[person setWeightInKilos:96]; <-- “setWeightInKilos” is no longer expressly referenced with our getters/setters.

If I Option/left-click “setWightInKilos” within the IDE, a pop-up box tells me that it’s declared in Person.h… but it’s not.

What am I missing here?


Could you post your code here so we could take a look?


The “weightInKilos” variable definition is still in Person.h, between the curly braces, just the (void)setWeightInKilos and (int)weightInKilos methods are no longer needed to be coded, as they are generated by the compiler as directed by @property/@synthesize. The compiler initial caps your variable name and prefix it with “set” for the setter. So it is there automatically. Hope that helps.


Thanks for the responses and sorry for the delay in responding.

Ah, ok, the compiler is adding the “set” prefix for me. I must have missed that! Thanks!