声明委托ivar时出现ARC错误 [英] ARC error when declaring delegate ivar
问题描述
我正在使用ARC(不,这不是NDA)。我在界面中声明我的ivar
I am using ARC (no, this is not NDA). I am declaring my ivar in my interface with
id itemDelegate;
然后我宣布财产:
@property(nonatomic,weak)id< mySecretDelegateYouAreNotSupposedToSeeOnSO> itemDelegate;
(由于ARC而弱而不是分配)
@property (nonatomic, weak) id<mySecretDelegateYouAreNotSupposedToSeeOnSO> itemDelegate;
(with weak instead of assign because of ARC)
在我的实现文件中,我只是合成它: @合成itemDelegate;
In my implementation file I simply synthesize it: @synthesize itemDelegate;
然而,我收到错误:
"Existing ivar 'ItemDelegate' for _weak property 'itemDelegate' must be _weak".
任何人都知道什么是错的?感谢您的帮助。
Anyone know what's wrong? Thanks for your help.
ARC - 自动引用计数
ARC - Automatic Reference Counting
推荐答案
尝试以下内容(示例来自: http://vinceyuan.blogspot。 com / 2011/06 / wwdc2011-session-323-introduction.html ):
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
请注意如何宣布ivar。
Please notice how the ivar is declared.
这篇关于声明委托ivar时出现ARC错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!