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: Ali Ozer <email@hidden>
- Date: Mon, 25 Jun 2001 18:29:08 -0700
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.
Please note that these functions are NOT public API in Mac OS X, and
thus can go away or get renamed at any point. Production code which is
supposed to run across several versions of the system should not use or
depend on these functions. However, for your testing or other purposes,
it's fine to use these.
Ali