Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

ARC forbids synthesizing a property with unspecified ownership or storage

I've created a @property of UIColor,

@property (nonatomic) UIColor *color;

and then I tried to synthesize it:

@synthesize color = _color;

but I receive an error:

ARC forbids synthesizing a property of Objective-C object with unspecified ownership or storage attribute

What does that mean?

All I'm trying to do is to create a property for a UIColor object which changes color.

like image 754
William Sham Avatar asked Dec 10 '11 23:12

William Sham


2 Answers

Change your property declaration to:

@property (nonatomic,strong) UIColor *color;

so that ARC knows it should be retained. This would have compiled without strong before ARC but it would be dangerous since the default was assign and the color would have been released unless it was retained elsewhere.

I would highly recommend the WWDC2011 video about ARC.

like image 128
Brian Avatar answered Oct 21 '22 04:10

Brian


You have to specify either strong or weak storage in the property declaration (next to nonatomic).

like image 24
JoePasq Avatar answered Oct 21 '22 05:10

JoePasq