当我使用LLVM Compiler 2.0时,我似乎遇到了新的错误,这是我之前没有的。重写符合协议的属性
我有一个名为DTGridViewDelegate协议定义为:
@protocol DTGridViewDelegate <UIScrollViewDelegate>
我有一个名为delegate
on DTGridView属性(的UIScrollView的一个子类,其本身具有delegate
属性)。这被定义为:
@property (nonatomic, assign) IBOutlet id<DTGridViewDelegate> delegate;
现在我得到的消息是:
DTGridView.h:116:63: error: property type 'id<DTGridViewDelegate>' is incompatible with type 'id<UIScrollViewDelegate>' inherited from 'UIScrollView'
因为我曾表示,DTGridViewDelegate符合UIScrollViewDelegate,我认为这将是确定以覆盖这个属性就是这样的,实际上这是第一个编译器提示有问题。
@property (nonatomic, assign) IBOutlet id<DTGridViewDelegate, UIScrollViewDelegate> delegate;
我想知道这是否是一个编译器的问题:
我已经宣布的财产为这种固定的错误?
我从http://boredzo.org/blog/archives/2009-11-07/warnings开启严格警告,使用Wolf的脚本:http://rentzsch.tumblr.com/post/237349423/hoseyifyxcodewarnings-scpt。这可能解释了为什么你没有看到警告/错误。 – 2011-03-05 15:04:40
虽然你完全正确,但我忘记了UITableViewDelegate,我首先将该代码作为基础!在我看来,第一种方式不应该为此发出警告。另外,我觉得很奇怪,UITableViewDelegate表示它符合NSObject,当它符合UIScrollViewDelegate时,它本身也符合NSObject。 – 2011-03-05 15:13:46
因此,在与@MikeAbdullah进一步讨论后,事实证明我需要在类接口之前放置协议声明。在编译器到达我的属性声明时,@protocol DTGridViewDelegate并不是说它符合。 –
2011-03-06 18:52:38