[cfe-dev] ARC and @synthesize of read only property

David Chisnall csdavec at swan.ac.uk
Tue Jul 19 12:50:36 PDT 2011


On 19 Jul 2011, at 19:46, Jean-Daniel Dupas wrote:

> When I'm trying to synthesize a read only property in obj-c, I get the following error.
> 
> error: ARC forbids synthesizing a property of an Objective-C object with unspecified storage attribute [4]
> 
> I understand why it is necessary to specify storage attribute to generate a setter, but why is it relevant to generate a getter ? 

The getter semantics also change:

- If the property is retained, then it will retain / autorelease the object, to ensure that it is not deallocated prematurely.

- If the property is weak, then it must use the weak read barrier function

- If the property is unsafe_unretained, then the getter will just return it directly.

Even in ARC mode, the compiler can't magically guess what you mean.  

David



More information about the cfe-dev mailing list