I’m trying to send messages from a class to one of its subclasses. I have a 
method that returns the class I want to forward to. If I use it in the 
following manner, it works:

+ (void)logout
{
    // subclasses handle it
    [[self classToUseForBackend] logout];
}

By setting breakpoints in this method and the subclass I can see that the 
message goes where i expect.

If I use it in the following manner, the message is not forwarded to the 
subclass with the identical signature. It ends up being re-sent to the 
superclass method (i.e. where I’m calling it here) and I get an infinite loop.

+ (NSString *)errorMessageForCode:(NSInteger)errorCode
{
    // subclasses handle it
    NSString *msg = [[self classToUseForBackend] errorMessageForCode:errorCode];
    
    return msg;
}

Can somebody explain to me why I’m getting this different behavior. Is there 
anything I can do to achieve my goal?
_______________________________________________

Cocoa-dev mailing list ([email protected])

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to [email protected]

Reply via email to