Forwarding messages to another class
Forwarding messages to another class
- Subject: Forwarding messages to another class
- From: Cosmo <email@hidden>
- Date: Sat, 06 Jun 2015 14:35:10 -0700
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@hidden)
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:
This email sent to email@hidden