kiran
kiran

Reputation: 4409

How to avoid import class and implement protocol?

One ViewController class already imported the UIView class into it. Now when implementing the protocol into same class.

Here @protocol class in already imported WeeklyView Class.

Now in Weekly View I got scenario to implement the @protocol method. So i need import PlanViewController into there.

It looks like classA import ClassB and ClassB import ClassA that is wrong.

How to avoid this behaviour in this case? and implement the protocol.

// ViewController class

#import <UIKit/UIKit.h>
#import "WeeklyView.h"
@protocol PlanViewControllerDelegate <NSObject>
@optional
-(void)nextWeekGlanceCategory :(NSString *)startweekDate endWeekDate:(NSString *)endWeekDate;
@end

// Another class Weeklyview

#import <UIKit/UIKit.h>
#import "PlanViewController.h"
@interface WeeklyView : UIView <UITableViewDelegate,UITableViewDataSource,PlanViewControllerDelegate>

Upvotes: 0

Views: 65

Answers (1)

AmirBenSalomon
AmirBenSalomon

Reputation: 9

Just put your protocol in separate header file.

To create protocol header file you can pick it like this: File->New->Objective-c File->Protocol.

Upvotes: 1

Related Questions