Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

ARC error when declaring delegate ivar

I am using ARC (no, this is not NDA). I am declaring my ivar in my interface with

id itemDelegate; 

I then declare the property:

@property (nonatomic, weak) id<mySecretDelegateYouAreNotSupposedToSeeOnSO> itemDelegate; (with weak instead of assign because of ARC)

In my implementation file I simply synthesize it: @synthesize itemDelegate;

However, I am getting the error:

"Existing ivar 'ItemDelegate' for _weak property 'itemDelegate' must be _weak". 

Anyone know what's wrong? Thanks for your help.

ARC - Automatic Reference Counting

like image 287
Dylan Reich Avatar asked Aug 11 '11 06:08

Dylan Reich


1 Answers

Try something like the following (example from: http://vinceyuan.blogspot.com/2011/06/wwdc2011-session-323-introducing.html):

@interface SomeObject : NSObject {    __weak id <SomeObjectDelegate> delegate; } @property (weak) id <SomeObjectDelegate> delegate; @end 

Please notice how the ivar is declared.

like image 76
Wolfgang Schreurs Avatar answered Oct 08 '22 13:10

Wolfgang Schreurs