Re: Using performSelector: on super
Re: Using performSelector: on super
- Subject: Re: Using performSelector: on super
- From: "Michael Ash" <email@hidden>
- Date: Tue, 5 Aug 2008 16:39:19 -0400
On Tue, Aug 5, 2008 at 8:41 AM, email@hidden
<email@hidden> wrote:
> Or am I on the wrong page entirely.
I'd suggest that you need to re-evaluate if this method should be private.
In OO languages with access controls, "private" usually means that
it's hidden from subclasses too. "Protected" is used to describe
things that can be accessed by subclasses but not be random externals.
Of course, ObjC supports protected methods even less than it supports
private methods.
But in general, if you want to call this method, you should show it to
the compiler. The simplest way to do that is to simply put it in the
superclass's header. Add a comment like "only call from a subclass" if
it's not supposed to be used in the general case. For things like this
I like to put the method in a separate category with an obvious name
like "Subclasses" to make the separation even more clear.
If you don't control this class, then you can declare the -close
method in a category in your own code, to tell the compiler that the
method really does exist.
And then in both cases, you can simply do [super close] instead of
this performSelector: stuff.
Mike
_______________________________________________
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