• 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 class methods from other class methods
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Calling class methods from other class methods


  • Subject: Re: Calling class methods from other class methods
  • From: Jeff Disher <email@hidden>
  • Date: Fri, 7 Feb 2003 00:02:20 -0500

On Thursday, February 6, 2003, at 11:33 PM, Ken Tozier wrote:

Given a class MyClass with two class methods, the first:

+ (BOOL) method1:(unichar) inChar
{
/* do stuff here */
}


Which of the following is the correct way to call class method 1 from class method 2?

+ (BOOL) method2:(unichar) inChar
{
return [self method1:inChar];
}

This is the correct one since it will still work properly if someone overrides the class method in a sub-class. I do remember someone saying that there was another issue which implied you should do it like this:

return [[self class] method1:inChar];

I am not sure of the details, however, since I haven't played around with class method inheritance aside from the extent to which that is used in basic class cluster designs.

Hope that helps,
Jeff Disher
President and Lead Developer of Spectral Class
Spectral Class: Shedding Light on Innovation
http://www.spectralclass.com/
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.

References: 
 >Calling class methods from other class methods (From: Ken Tozier <email@hidden>)

  • Prev by Date: Re: Drag&Drop onto Button
  • Next by Date: Re: Click Through Bug?
  • Previous by thread: Calling class methods from other class methods
  • Next by thread: bad memory access problem
  • Index(es):
    • Date
    • Thread