I recently tried to compile an older Xcode project (which used to compile just fine), and now I'm seeing a lot of errors of this form:
error: writable atomic property 'someProperty' cannot pair a synthesized setter/getter with a user defined setter/getter
The code pattern which causes these errors always looks like this:
// Interface:
@property (retain) NSObject * someProperty;
// Implementation:
@synthesize someProperty; // to provide the getter
- (void)setSomeProperty:(NSObject *)newValue
{
//..
}
I can see why the error is being generated. I tell the compiler to synthesize my property accessors (both getter and setter), and then immediately afterward I override the setter manually. That code has always smelled a little off.
So, what is the proper way to do this? If I use @dynamic
instead of @synthesize
, I will have to write the getter as well. Is that the only way?