Re: Hiding superclass methods
Re: Hiding superclass methods
- Subject: Re: Hiding superclass methods
- From: Thomas Lachand-Robert <email@hidden>
- Date: Fri, 10 May 2002 00:17:14 +0200
Le jeudi 9 mai 2002, ` 11:36 , Brock Brandenberg a icrit :
Is there a way in Obj-C to hide a superclass method so that compiler
checking would catch/flag any access to that method? I have an NSView
subclass that is instantiated in code at runtime that has a custom
initWithFrame:data: method that, in turn, calls the initWithFrame: method.
I'd like to prevent my accidental use of the standard initWithFrame
method, if possible, but haven't found any relevant information in the
Obj-C book.
You can't do that at the compiler level, but you can redefine the method
in your class, in such a way that it throws an exception (or display an
error messgae, whatever). That's the usual way to "remove inheritance" of
a method.
When you control the code for both classes (which is definitely not the
case for you, you can't access the code for NSView), then it is possible
to get a warning from the compiler, by defining the mother class's method
in a category in a separate header file.
Thomas Lachand-Robert
********************** email@hidden
<< Et le chemin est long du projet ` la chose. >> Molihre, Tartuffe.
_______________________________________________
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.