Re: nil messaging? Is it safe?
Re: nil messaging? Is it safe?
- Subject: Re: nil messaging? Is it safe?
- From: "Timothy J. Wood" <email@hidden>
- Date: Thu, 26 Sep 2002 14:28:41 -0700
The portion of the message you quoted was not well phrased.
If you directly send a message to nil, then the quote from the ObjC
manual is correct.
If you set the target of a AppKit NSControl, then the action will
propagate up the responder chain until something that implements that
action is found.
See the documentation of -[NSApplication sendAction:to:from:] for the
details.
-tim
On Thursday, September 26, 2002, at 12:39 PM, Gerben Wierda wrote:
I did not see the original message, but
You certainly CAN send messages to nil! I do it all the time. It
sends the
message up the responder chain.
"up the responder chain"?? According to the Obj-C manual sending a
message to nil
"is valid as long as the message returns an object; if it does, a
message sent to nil will return nil. If the message sent to nil
returns anything other than an object, the return value is undefined"
Now, I do not understand this. How can the compiler or the runtime
system know what the message will return? After all, nil has no class,
so there is no way of knowing the signature of the message (that is,
the return value).
I was under the impression that any message sent to nil will just
return nil and that's it. No harm done. But both statements above do
suggest something else is going on. So: is it safe to send messages to
nil? What does the runtime system exactly do with messages like that?
Thanks,
G
_______________________________________________
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.
_______________________________________________
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.