The name of the synthesized getter for property xyz
is the same as the name of the property, i.e. xyz
. It is not getXyz
. Only the setter gets prefixed with a "set", becoming setXyz:
That is why your code
NSLog(@"Str = %@",[obj getStr]);
does not compile. Changing to
NSLog(@"Str = %@",[obj str]);
will fix the problem.
Note: when you let Xcode synthesize a property for you, a variable to "back" that property is also created. You do not need to declare an instance variable str
in addition to the property str
.