Re: Sending messages to nil -- anyway to detect this?
Re: Sending messages to nil -- anyway to detect this?
- Subject: Re: Sending messages to nil -- anyway to detect this?
- From: Art Isbell <email@hidden>
- Date: Tue, 19 Jun 2001 20:27:29 -1000
On Tuesday, June 19, 2001, at 06:15 PM, Michael P. Rogers wrote:
Is there a mechanism in Objective-C to detect when a message
has been sent to a nil pointer? There are times when it'd be
handy if the run-time system flagged it as an error.
There is no direct run-time support for this, but of course
you could "turn on" such an error selectively:
if (receiver != nil)
[receiver doSomething];
else
[NSException raise:@"NilException" format:@"Message
doSomething sent to nil object"];
Art