Skip navigation.
 
mlRe: Implementing delegation
FROM : Tobias Peciva
DATE : Sun Nov 21 21:35:13 2004

On 20/11/2004, at 12:12 PM, Bruce Toback wrote:

> On Nov 19, 2004, at 4:08 PM, Bruce Toback wrote:
>

>> Okay, that looks very much like what I'm doing. But using the code
>>
>>    if ([delegate
>> respondsToSelector:@selector(myObject:wantsToTellYou:)])
>>      [delegate myObject: self wantsToTellYou: something];
>>
>> I get the warning
>>
>>  cannot find method '-myObject:wantsToTellYou:'; return type 'id'
>> assumed

>
> I figured out the difference: the sample on cocoadevcentral declares
> the interface to the delegate as a category on NSObject. This makes
> the compiler happier, since it has an interface.


Or you could just use something along the lines of:
if([delegate respondsToSelector:...])
{
    [delegate performSelector:...];
}

Invocations would do the job as well.

That said, it would be interesting to know what Apple's implementation
looks like.

Cheers,
Tobias Peciva
Pharos Systems

Related mailsAuthorDate
mlImplementing delegation Bruce Toback Nov 19, 20:51
mlRe: Implementing delegation Joakim Danielson Nov 19, 23:56
mlRe: Implementing delegation Bruce Toback Nov 20, 00:08
mlRe: Implementing delegation Bruce Toback Nov 20, 00:12
mlRe: Implementing delegation Douglas A. Welton Nov 20, 14:28
mlRe: Implementing delegation Tobias Peciva Nov 21, 21:35
mlRe: Implementing delegation Fritz Anderson Nov 23, 21:15