Finding the sender of a notification and avoid dangling ones


I have several text fields in my app and they all have to be controlled char-by-char. So I made all of them send a notification to my appDelegate (a sort of bottleneck easy to maintain). But of course I have to verify which textField is posting the notification. So I wrote:

	on controlTextDidChange_(aNotification)
        set sender to aNotification's object()
        if sender is textField_1 then
        else if
        end if
	end controlTextDidChange_

But if the user clicks on something else while editing the field (an image, a textView) I get this:

2011-04-10 18:16:07.331 AutoText[75353:903] *** -[AutoTextAppDelegate controlTextDidChange:]: -[NSTextField object]: unrecognized selector sent to instance 0x20003ff00 (error -10000)

How can I avoid this?

Thanks for your help!

Ok. never invoke controlTextDidChange_(aNotification) as an IB action. Silly me. :rolleyes: