S.J
S.J

Reputation: 3071

some confusion regarding delegates

@protocol msgRcvdFrom <NSObject>

@optional
-(void) msg:(NSString *)msg from:(NSString *)from;
.
.
. 
if([delegate respondsToSelector:@selector(msg:from:)])
{
    [delegate msg:body from:user];
}

this is my delegate and two different classes are using it, when respondsToSelector is called will both classes will be notified? or if I want to notify one class at a time. Please clear this confusion.

Upvotes: 1

Views: 56

Answers (1)

Francesco
Francesco

Reputation: 1848

delegate usually is an object (declared as id< msgRcvdFrom>). So.. when you call respondToSelector on delegate you are asking to that particular object if it has the method or not!

Upvotes: 2

Related Questions