Re: ObjC error messages
Re: ObjC error messages
- Subject: Re: ObjC error messages
- From: Marcel Weiher <email@hidden>
- Date: Thu, 14 Feb 2002 15:00:27 +0100
On Thursday, February 14, 2002, at 01:16 PM, Malte Tancred wrote:
As Ondra Cada suggested -doesNotRecognizeSelector: is causing the
NSLog(). From the documentation on NSObject:
...
- (void)doesNotRecognizeSelector:(SEL)aSelector
Handles aSelector messages the receiver doesn't recognize. The
run-time system invokes this method whenever an object receives
an aSelector message it can't respond to or forward. This method,
in turn, raises an NSInvalidArgumentException, and generates an
error message.
...
Raising an exception is the correct way to handle this. However,
printing out error messages to stderr without anyone asking for
it is not.
This is really just the default behavior for unrecognized messages, and
it seems quite reasonable that the default is to print a message, as
this is an exceptional situation that (in its unhandled state) is
comparable to a type-error that would prevent compilation in a strict
statically-typed language (and produce an error message).
A request to Apple: could the error message produced by the
method -doesNotRecognizeSelector: be made optional? I would prefer
"opt-in" optional.
You have several options for handling this error yourself.
1. override -doesNotRecognizeSelector: either only in your own objects
or globablly in a category
2. override -forwardInvcation: in order to handle situations in which
you don't actually consider it an error
Marcel
--
Marcel Weiher Metaobject Software Technologies
email@hidden www.metaobject.com
Metaprogramming for the Graphic Arts. HOM, IDEAs, MetaAd etc.
_______________________________________________
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.