Duplicate protocol definition

心不动则不痛 提交于 2020-01-07 06:14:12

问题


Getting warning message that Duplicate protocol definition of ModalViewDelegate is ignored

Defined protocol in modalviewcontroller.h file

@protocol ModalViewDelegate;
-(void)dismissView:(id)sender;  
@interface Modalviewcontroller : UIViewController 
{
 id<ModalViewDelegate>delegate;
}
@property (nonatomic, assign) id<ModalViewDelegate>delegate;
@end

In the Modalviewcontroller.m file synthesize delegate

In Mainviewcontroller.h file

@protocol ModalViewDelegate 
-(void)didDismissModal:(id)sender;
@end
@interface Mainviewcontrollerontroller : UIViewController <ModalViewDelegate>
-(void)showModal:(id)sender;

In the Mainviewcontroller.m not synthesize delegate

Am I supposed to delegate in mainviewcontroller.m file too?

Why I'm getting warning message of duplicate protocol definition?


回答1:


Try to remove @protocol ModalViewDelegate; in modalviewcontroller.h and import Mainviewcontroller.h in this file.




回答2:


You are defining the protocol twice one in mainviewcontroller.h and the other in modalViewController.h...thats why you are getting the warning...



来源:https://stackoverflow.com/questions/8901352/duplicate-protocol-definition

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!