Possible Duplicate:
property not working with getter AND setter
this is the problem I'm facing: I'm using iOS 6. I declare a property in the header file:
@property (nonatomic) CGFloat scale;
Then in the implementation, I create my own getter/setter like this:
#define DEFAULT_SCALE 0.90
- (void)setScale:(CGFloat)scale
{
if(_scale != scale) {
_scale = scale;
[self setNeedsDisplay];
}
}
- (CGFloat) scale
{
if(!_scale) {
return DEFAULT_SCALE;
} else {
return _scale;
}
}
the problem is that _scale is not recognized by compiler. I get error "Use of undeclared identifier '_scale'.
If I remove the getter or the setter, then it works fine, but I can't keep both. If I do, I have to add @synthesize scale = _scale
to avoid the error. Can someone explain why?
Thanks