• 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: Calling a super call method from and instance
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Calling a super call method from and instance


  • Subject: Re: Calling a super call method from and instance
  • From: Jonathan Hess <email@hidden>
  • Date: Thu, 7 May 2009 13:52:49 -0700

Hey Dave -

Usually wanting to do something like this points to some design flaw, but if you really want to invoke classA's implementation there are a number of ways to do it.

One way would be to put a category on MyClassB like this:

@implementation MyClassB(PassThrough)
- (void)aboutMySuperClass {
	[super about Me];
}
@end

Then from "-(void) someMethod:(MyClassB*) myClass" invoke "[myClass aboutMySuperClass]".

Good Luck -
Jon Hess

You could put a category on MyClassB
On May 7, 2009, at 1:37 PM, David Alter wrote:

In Objective-C 1.0 (not 2.0 ) is there a way to call a super class method if
I have a reference to the class
See bellow
@interface MyClassA : NSObject {
}
-(void) aboutMe ;
@end
@implementation MyClassA


-(void) aboutMe ;
{
NSLog(@"I'm Class A");
}
@end

@interface MyClassB :MyClassA {
}
-(void) aboutMe ;
@end
@implementation MyClassB
-(void) aboutMe ;
{
NSLog(@"I'm Class B");
}
@end

-(void) someMethod:(MyClassB*) myClass
{

//I want to call MyClassB's super of aboutMe. This should output "I'm Class
A"


}
thanks for the help

-dave
_______________________________________________

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

_______________________________________________

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: 
 >Calling a super call method from and instance (From: David Alter <email@hidden>)

  • Prev by Date: Re: Strategy for acting on changes in child objects?
  • Next by Date: Re: Text color in NSOutlineView's selected row
  • Previous by thread: Calling a super call method from and instance
  • Next by thread: Key-Value Observing: light-weight or heavy-weight?
  • Index(es):
    • Date
    • Thread