重复的协议定义 [英] Duplicate protocol definition

查看:107
本文介绍了重复的协议定义的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

收到警告消息,忽略ModalViewDelegate的重复协议定义



modalviewcontroller.h文件中定义的协议

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

在Modalviewcontroller.m文件中合成代理



在Mainviewcontroller.h文件中

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

在Mainviewcontroller.m中没有合成代理



<我是否应该在mainviewcontroller.m文件中委托?



为什么我收到重复协议定义的警告消息?

解决方案

尝试在 modalviewcontroller.h中删除 @protocol ModalViewDelegate; 并在此文件中导入 Mainviewcontroller.h


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?

解决方案

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

这篇关于重复的协议定义的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆