2009-10-23 136 views
3

我使用的是MulticastDelegate类,它是xmpp框架的一部分并被拍摄here它对我来说非常适合!不过我警告:ObjectiveC中的MulticastDelegate

“MulticastDelegate”可能不响应 “的someMethod”

有什么办法来避免此类的警告? 在此先感谢。

+0

到多播委托首部的链接是死的。这是一个到维基页面的链接:http://code.google.com/p/xmppframework/wiki/MulticastDelegate。我找不到旧的课程,但浏览源代码后,我发现一个基于GCD的新课程:http://code.google.com/p/xmppframework/source/browse/Utilities/GCDMulticastDelegate.h – chrish

+0

我无法访问找到在这个问题中引用的'MulticastDelegate' - 所以在这里建立了自己的:http://www.scottlogic.co.uk/blog/colin/2012/11/a-multicast-delegate-pattern-for-ios-控制/ – ColinE

回答

2

这是什么样的someMethod?您是否包含MulticastDelegate.h标题?


更新:啊哈,在这种情况下,你需要告诉该委托实现Notifier接口编译:

#import "MulticastDelegate.h" 

@protocol Notifier 
- (void) someMethod; 
@end 

@interface Manager 
{ 
    MulticastDelegate <Notifier> delegate; 
} 
@end 

这应该做的。但是这不是代码有点腥吗?你怎么知道delegate implements someMethoddelegate是一个普通的MulticastDelegate?你在示例中省略了什么?

+0

非常感谢!而已。 – Dmytro

0

只要您导入了"MulticastDelegate.h"并且某个方法是"MulticastDelegate.h"中声明的类的公共接口的一部分,则不应该得到此警告。

GCC仅在您向未公开声明回复该消息的对象发送消息的情况下发出此警告。

0

我有一个协议

@protocol Notifier 
-(void) someMethod; 
@end 

和类

#import "MulticastDelegate.h" 

@interface Manager 
{ 
     MulticastDelegate delegate; 
} 
@end 

某处实现文件

delegate= [[MulticastDelegate alloc] init]; 
..... 
- (void)addDelegate:(id)_delegate 
{ 
    [delegate addDelegate:_delegate]; 
} 

然后

[delegate someMethod]; 

上面的行会导致我在问题中提到的警告。

'MulticastDelegate' 可以不 响应 '的someMethod'