• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Forwarding messages to another class
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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


  • Follow-Ups:
    • Re: Forwarding messages to another class
      • From: Kyle Sluder <email@hidden>
    • Re: Forwarding messages to another class
      • From: Quincey Morris <email@hidden>
  • Prev by Date: Re: why is this Swift initializer legal
  • Next by Date: Re: Forwarding messages to another class
  • Previous by thread: Re: why is this Swift initializer legal
  • Next by thread: Re: Forwarding messages to another class
  • Index(es):
    • Date
    • Thread