views:

67

answers:

3

I'm using MulticastDelegate class which is part of xmpp framework and taken here It works perfect for me! However I got warning:

'MulticastDelegate' may not respond to 'someMethod'

Is there any way to avoid the warning for this class? Thanks in advance.

+1  A: 

What kind of someMethod is that? Did you include the MulticastDelegate.h header?


Update: Aha, in that case you need to tell the compiler that the delegate implements the Notifier interface:

#import "MulticastDelegate.h"

@protocol Notifier
- (void) someMethod; 
@end

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

This should do. But isn’t the code a bit fishy? How do you know that the delegate implements someMethod when delegate is a plain MulticastDelegate? Are you omitting something in the example?

zoul
Thanks a lot!!! That's it.
Dmytro
A: 

As long as you have imported "MulticastDelegate.h" and someMethode is part of the public interface of the class as declared in "MulticastDelegate.h", you shouldn't get this warning.

GCC issues this warning only on the ocassion you send a message to an object which does not publicly declare to respond to that message.

Johannes Rudolph
A: 

I have a protocol

@protocol Notifier
 -(void) someMethod; 
@end

and class

#import "MulticastDelegate.h"

@interface Manager
{
       MulticastDelegate delegate; 
}
@end

somewhere in the implementation file

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

and then

[delegate someMethod];

Line above causes the warning I mentioned in my question.

'MulticastDelegate' may not respond to 'someMethod'

Dmytro