• 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: Question about Style wrt "private" methods
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Question about Style wrt "private" methods


  • Subject: Re: Question about Style wrt "private" methods
  • From: Jim Correia <email@hidden>
  • Date: Wed, 18 Nov 2009 14:15:20 -0500

On Nov 18, 2009, at 1:49 PM, Jens Alfke wrote:

This is unfortunately true. The danger is that if you add an _- prefixed method to your class, it might conflict with a private method declared in a superclass. If this happens your method will override the internal one, and Really Bad Things will probably happen. It's a rare problem but it has happened before. (And even if everything works well now, any future OS update might add a new private method in a superclass that breaks your code. Again, this has actually happened.)

This problem is just not restricted to private methods, or additions through categories. You can also run afoul of a namespace conflict with a public method in your subclass.


Suppose you have a subclass of NSView which adds - reallyNiceMethodThatOughtToBeInAppKit. If Apple adds such a method in the next OS release, the same kinds of problem can result. (Similar problems when you extend delegate protocols for your subclasses too.)

This problem is much less insidious than the category problem, but the potential does exist. (For both private and public methods.)

- Jim

_______________________________________________

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: Question about Style wrt "private" methods
      • From: "Sean McBride" <email@hidden>
    • Re: Question about Style wrt "private" methods
      • From: Michael de Haan <email@hidden>
    • Re: Question about Style wrt "private" methods
      • From: Jens Alfke <email@hidden>
References: 
 >Question about Style wrt "private" methods (From: Michael de Haan <email@hidden>)
 >Re: Question about Style wrt "private" methods (From: Jens Alfke <email@hidden>)

  • Prev by Date: SB won't create an element on 10.5
  • Next by Date: Help with Background Tasks
  • Previous by thread: Re: Question about Style wrt "private" methods
  • Next by thread: Re: Question about Style wrt "private" methods
  • Index(es):
    • Date
    • Thread