Before invoking a delegation method, make sure the delegate implements it by sending it a
respondsToSelector: message.
- (void)someMethod {
if ( [delegate respondsToSelector:@selector(operationShouldProceed)] ){
if ( [delegate operationShouldProceed] ) {
// do something appropriate
} }
}
Hi
In the quest for a better UI framework :), I was re rereading about delegate in Cocoa.
A delegating object will delegate certain operations to a delegate object (check the attachment).
Now I was wondering why this is not a simple delegation they wrote:
The delegating object sends a message only if the delegate implements the method. It makes this discovery by invoking the NSObject method respondsToSelector: in the delegate first.
Cocoa Fundamentals Guide (TP40002974 6.0.0)