Re: ObjC error messages
Re: ObjC error messages
- Subject: Re: ObjC error messages
- From: Malte Tancred <email@hidden>
- Date: Thu, 14 Feb 2002 14:34:52 +0100
On thursday, february 14, 2002, at 01:48 , Ondra Cada wrote:
I, for one, rather like this behaviour. It seems to me that you _asked_
for
it by using a non-recognized and non-forwarded message ;). Nevertheless,
No, I didn't ask for an error message on the console, I asked for
an exception.
If I don't catch the exception however, perhaps then is an error message
to the console appropriate.
MT> A request to Apple: could the error message produced by the
MT> method -doesNotRecognizeSelector: be made optional? I would prefer
MT> "opt-in" optional.
I don't think you would really want to suppress the warning for others'
code.
When do you need these warnings Ondra? On a day to day basis running a
hopefully well-tested application? Or when developing new code?
By the way, is anyone _depending_ on the output generated by sending
an unrecognized method to an object? I shiver at the thought, but perhaps
I'm missing something obvious here.
If at some place in your app you don't catch an exception, wouldn't it
be enough to let the top level handler take care of the logging, just
as the rest of the uncaught exceptions are being delt with?
For your own code I guess the optionality can be achieved by very
simple
@implementation NSObject (GetRidOfTheConsoleWarningIDontLike)
-(void)doesNotRecognizeSelector:(SEL)aSelector {
[NSException raise:NSInvalidArgumentException format:...];
}
@end
Note that I *HAVEN'T* tested this, there could be some caveat hidden!
I know how to implement a method.
(it does work as a category on a specific class. Haven't tried,
and won't bother, replacing NSObject's implementation).
/malte
--
Malte Tancred
Computer programmer, Oops AB, Sweden
mailto:email@hidden
http://www.oops.se/
_______________________________________________
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.