• 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
Re: subclassing with conditional method overriding
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: subclassing with conditional method overriding


  • Subject: Re: subclassing with conditional method overriding
  • From: Brent Gulanowski <email@hidden>
  • Date: Sat, 5 Sep 2009 10:01:42 -0400

@implementation B
- (void)handleTask {
  if(condition) {
    [super handleTask];
    return;
  }

  // B implementation

  return;
}
@end

On Sat, Sep 5, 2009 at 6:25 AM, Alex Reynolds<email@hidden> wrote:
> Let's say I have a class interface and implementation, as follows:
>
> ---
> @interface A : NSObject {
>   ...
> }
> - (void) handleTask;
> @end
>
> @implementation A
> ...
> - (void) handleTask {
>   // do stuff specific to A object type...
> }
> ---
>
> Let's say I then subclass A and override -handleTask:
>
> ---
> @interface B : A {
>   ...
> }
> - (void) handleTask;
> @end
>
> @implementation B
> ...
> - (void) handleTask {
>   // do stuff specific to B object type...
> }
> ---
>
> If I instantiate a variable of type B, is there a way to conditionally use
> the -handleTask method from either class A or B? For example, by casting to
> (A *) when calling -handleTask?
>
> Apologies in advance, if this is a dumb question. Thanks for your advice.
>
> -Alex
> _______________________________________________
>
> 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
>



--
Brent Gulanowski
_______________________________________________

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

References: 
 >subclassing with conditional method overriding (From: Alex Reynolds <email@hidden>)

  • Prev by Date: Re: Having problem with fetch request in NSDocument based application
  • Next by Date: Re: Binding table columns that change at runtime
  • Previous by thread: Re: subclassing with conditional method overriding
  • Next by thread: Easy Question re NSWindowController
  • Index(es):
    • Date
    • Thread