What happens when an objective_C program sends a message to nil?
The default behavior of objective_C, using gcc,
is to do nothing...no warning, no crash, nothing.
This can make it hard to find bugs.
To override this behavior, all you have to do is include
a function like the following in your program:
///////////////////////////////////////////////////////////////////////
// nil_method
// include this if you want this message printed whenever
// a message was sent to nil.
//#ifdef THIS
id nil_method (id receiver, SEL op, ...)
{
fprintf(stderr,"The message `%s' was sent to nil\n", sel_get_name (op));
// a standard swarm approach:
//raiseEvent (WarningMessage, "`%s' was sent to nil\n", sel_get_name (op));
return nil;
}
//#endif
For instance, you can put this in your main.m, and you
can turn it on and off by commenting out/ uncommenting
the #ifdef/#endif lines.