具有assign属性的属性委托的现有实例变量委托必须是unsafe_unretained

时间:2013-03-19 19:01:20

标签: iphone objective-c automatic-ref-counting xcode4.5

上获取错误
@protocol TapDetectingImageViewDelegate;

@interface TapDetectingImageView : UIImageView {
id <TapDetectingImageViewDelegate> tapDelegate;

@property (nonatomic, assign) id <TapDetectingImageViewDelegate> tapDelegate;

@synthesize tapDelegate;

尝试了所有的事情

 _weak id <TapDetectingImageViewDelegate> tapDelegate;

 @property (weak) id <TapDetectingImageViewDelegate> tapDelegate;

甚至尝试了这个

_unsafe_unretained id <TapDetectingImageViewDelegate> tapDelegate;

@property (_unsafe_unretained) id <TapDetectingImageViewDelegate> tapDelegate;

甚至尝试删除实例变量定义,因为合成在使用ARC模式时会处理它。

但是仍然没有办法消除这个错误。

如果有人可以帮我解决这个错误。

感谢。

1 个答案:

答案 0 :(得分:0)

我是Obj-C的新手,我找到了这个解决方案https://stackoverflow.com/a/10080387/3867557 并且您的代码应如下所示:

@protocol TapDetectingImageViewDelegate;
@interface TapDetectingImageView : UIImageView 
@property (nonatomic, assign) id <TapDetectingImageViewDelegate> tapDelegate;

希望有所帮助。

相关问题