错误:在iphone sdk中找不到协议声明

时间:2012-02-27 12:01:30

标签: iphone objective-c protocols

我在使用自定义协议时遇到错误。

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

#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

1 个答案:

答案 0 :(得分:1)

您有一个循环导入参考。将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