简体   繁体   English

错误:在iPhone SDK中找不到协议声明

[英]Error: Cannot find protocol declaration in iphone sdk

I am getting an error when I am using a custom protocol. 使用自定义协议时出现错误。

TKCalendarMonthView.h TKCalendarMonthView.h

#import "ViewController.h"

@protocol EventViewProtocol;

@interface TKCalendarMonthView : UIView <PSMonthSelectedDelegate, PSYearSelectedDelegate,UIGestureRecognizerDelegate> {

    id <EventViewProtocol> __unsafe_unretained eventDelegate;

}

@property (nonatomic,unsafe_unretained) id <EventViewProtocol> eventDelegate;

@end

@protocol EventViewProtocol <NSObject>

- (void)navigateToEventView;

@end

ViewController.h ViewController.h

#import <UIKit/UIKit.h>
#import "ELScrollView.h"
#import "TKCalendarMonthView.h"

@interface ViewController : UIViewController <UIGestureRecognizerDelegate, EventViewProtocol> //At this line I am getting the error as "Cannot find protocol declaration for EventViewProtocol"

@property (nonatomic, strong) UIColor* horizontalBgColor;
@property (nonatomic, strong) UIColor* verticalBgColor;


@end

You have a circular import reference. 您有一个循环导入参考。 Change TKCalendarMonthView to this: 将TKCalendarMonthView更改为此:

@class ViewController;
@protocol EventViewProtocol;

@interface TKCalendarMonthView : UIView <PSMonthSelectedDelegate, PSYearSelectedDelegate,UIGestureRecognizerDelegate> {

    id <EventViewProtocol> __unsafe_unretained eventDelegate;

}

@property (nonatomic,unsafe_unretained) id <EventViewProtocol> eventDelegate;

@end

@protocol EventViewProtocol <NSObject>

- (void)navigateToEventView;

@end

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM