Re: private methods?
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/