• 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: private methods?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: private methods?


  • Subject: Re: private methods?
  • From: Norbert Heger <email@hidden>
  • Date: Fri, 19 Oct 2001 12:22:39 +0200

Ondra Cada <email@hidden> wrote:

> compiler would issue a warning of unknown message, but the method _will_ be
> called properly. Due to the dynamic object system it is alas impossible to
> have really internal methods. Therefore, you should at least use underscores
> like in this example.

But you have to be careful with those underscore method names if you extend
existing classes via subclassing or categories. Apple also uses leading
underscores for its private methods. If the name you choose happens to be
equal to an already existing private method name, it is very likely that you
break existing functionality - e.g. NSView has lots of private methods, some
of them have such ordinary names as _showBorder or _drawMatrix.

Unfortunately, there seem to be lots of private framework mehods _without_ a
leading underscore as well (see my posting "Undocumented NSString API" a few
days ago). It's very likely that developers implement convenience methods in
NSString/NSMutableString categories such as:

- (id)mutableSubstringFromRange:(NSRange)aRange;
- (BOOL)matchesPattern:(id)aPattern;
- (void)appendCharacter:(unichar)aCharacter;
- (void)deleteLastCharacter;

not knowing that these methods already exist and that their categories
possibly break the original implementation!

Best Regards, Norbert

_____________________________________________
Norbert Heger, Objective Development
http://www.obdev.at/


  • Follow-Ups:
    • Re: private methods?
      • From: Ondra Cada <email@hidden>
References: 
 >Re: private methods? (From: Ondra Cada <email@hidden>)

  • Prev by Date: Re: private methods?
  • Next by Date: Re: private methods?
  • Previous by thread: Re: private methods?
  • Next by thread: Re: private methods?
  • Index(es):
    • Date
    • Thread