Re: Private, Protected methods in Obj C?
Re: Private, Protected methods in Obj C?
- Subject: Re: Private, Protected methods in Obj C?
- From: Andy Lee <email@hidden>
- Date: Wed, 3 Apr 2002 17:51:56 -0500
At 4:01 PM -0500 4/3/02, email@hidden wrote:
I believe that the methods are still public, but if they aren't visible
publicly, then nobody knows to use them. This means that they will still be
inherited, and so they are actually similar to protected methods.
Interesting, I hadn't thought of it this way. You are right,
undeclared methods are more like protected methods than private
methods, because they can be overridden, and in fact *will* be
overridden if you reuse a method name in a subclass, whether you were
aware of the superclass's method or not.
At 11:24 PM +0200 4/3/02, Ondra Cada wrote:
Private
methods can't really be achieved
Actually they can -- a static function is just a private,
non-inheritable method in fact ;)
I see the smiley there, but I just want to point out a couple of
little nits (mainly because it took me a while to think of them and
convince myself static functions aren't an *exact* substitute for
private methods).
* You can't use a selector to refer to a static function. Not that
it matters in any case I can think of, but maybe one could contrive a
case where it does matter.
* To the extent that a static function is like a method, it's only
like a *class* method. You can't quite make it emulate an instance
method, even by passing self as an argument, because the compiler
won't allow the "super" keyword outside of a method.
--Andy
_______________________________________________
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.