When I call respondsToSelector in an ARC environment, I get the following error message Automatic Reference Counting Issue No known instance method for selector respondsToSelector:
This is the header
#import <AppKit/AppKit.h>
@class MTScrollView;
@protocol MTScrollViewDelegate
-(void)scrollViewDidScroll:(MTScrollView *)scrollView;
@end
@interface MTScrollView : NSScrollView
{
}
@property(nonatomic, weak) id<MTScrollViewDelegate>delegate;
@end
This is the implementation file
#import "MTScrollView.h"
@implementation MTScrollView
@synthesize delegate;
- (void)reflectScrolledClipView:(NSClipView *)aClipView
{
[super reflectScrolledClipView:aClipView];
if([delegate respondsToSelector:@selector(scrollViewDidScroll:)])
{
[delegate scrollViewDidScroll:self];
}
}
@end
Any suggestions on why I am getting this error?
本文详细解析了在Objective-C ARC环境下调用respondsToSelector时出现的‘Automatic Reference Counting Issue’错误的原因及解决方案。通过示例代码,深入探讨了如何让协议遵循NSObject以解决此问题。
585

被折叠的 条评论
为什么被折叠?



