Possible Duplicate:
error: writable atomic property cannot pair a synthesized setter/getter with a user defined setter/getter
I am getting the following warning: Writable atomic property 'result' cannot pair a synthesized setter/getter with a user defined setter/getter
This is how I setter/getter it:
@property (retain, getter=getResult) NSString *result;
@synthesize result;
I get the warning in the bolded/italicized line below:
***- (NSString *)getResult***
{
if (result == nil)
self.result = [[[NSString alloc] initWithData:data encoding:NSUTF8StringEncoding] autorelease];
return result;
}
Any ideas on how to fix it?
Thanks!
Synthesizing an atomic property generates a getter and setter which use a lock to ensure that the value is always fully retrieved or set in a multithreaded environment.
Either change your property declaration to:
@property (nonatomic, retain) NSString *result;
Or define both accessors yourself and implement your own locking mechanism to guarantee atomicity.
When you set the @property for a setter, the compiler will automatically make a setter that goes by the name getResult(you can not see it though). So, when you make a setter yourself, the compiler warns you that it has already done that for you. But this does not cause any issues with functionality because, as you might've seen with breakpoints, this code is still called. So, you can either remove the code for making a setter in the @property or you can make a setter that takes does not have the same name and does not take the same arguments as the default setter and call it yourself, like
- (NSString *)getResult(id data){}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With