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: Chuck Fleming <email@hidden>
- Date: Thu, 21 Jun 2001 00:11:51 -0700
Hi,
The runtime has a mechanism for detecting this. You can register a
callback to detect messages being sent to nil.
void objc_setNilObjectMsgHandler(NilObjectMsgCallback
nilObjMsgCallback)
where the prototype for the call back is
typedef void (*NilObjectMsgCallback) (id nilObject, SEL selector)
See objc/objc-runtime.m (part of Darwin) for details. For gory details
look for the label LMsgSendNilSelf: in objc-msg-ppc.s.
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.
Chuck
"Damnit Jim, I'm a programmer not an engineer."