In each of the four examples below, we'll describe the problem, show the solution working in the application, and then review the relevant parts of the code. This method takes three arguments: a Selector specifies the message to send.A selector is sort of the "name" of a method, a very distant cousin of C's function pointers."], except that the message gets delivered later, not "while you wait".Also, of course, if print String: returns a value, you can't get that value when using delayed messaging, because you want to continue before the message even gets received.But keep in mind that if you do want to pass something, it must be an object - not an integer or other C type.
Quickly click on the red rectangle one or more times; it changes color with every click.an Argument is an optional object to send with the message.If you don't want to pass anything, you can pass nil.The implementation, in Color View.m, overrides some methods from NSView - init With Frame:, which all views use to initialize; draw Rect:, which displays the view's contents; and mouse Down:, which handles mouse clicks. The mouse Down: method (Listing 3) is also short, but does a lot more.It updates the view's color, based on the event's click count - the NSEvent method click Count returns 1 for a click, 2 for a double-click, etc.