error: writable atomic property cannot pair a synthesized setter/getter with a user defined setter/getter

I had the same problem and after doing a bit of research, here is my conclusion about this issue:

The compiler warns you about a @property that you declared as atomic (i.e. by omitting the nonatomic keyword), yet you provide an incomplete implementation of how to synchronize access to that property.

To make that warning disappear:

If you declare a @property to be atomic then do one of the following:

  • use @dynamic or;
  • use @synthesize and keep the synthesized setter and getter or;
  • provide a manual implementation of both the setter and the getter (without using one of the above directives).

If you declare the @property with (nonatomic) then you can mix manual and synthesized implementations of getters and setters.

Update: A Note on Property Auto-Synthesis

As of LLVM 4.0, CLang provides auto-synthesis for declared properties that are not @dynamic. By default, even if you leave out the @synthesize, the compiler will provide getter and setter methods for you. However, the rule for atomic properties is still the same: Either let the compiler provide both the getter and the setter, OR implement them both yourself!

Leave a Comment