Arg! Deleted a button but code still pops into my script

I had a popup button that I had a “on choose menu item theObject” script linked to. I deleted that button and replaced it with a combo box (but kept the Applescript name of it the same). But now I no longer need the “on choose menu item theObject” script, but every time I resave my InterfaceBuilder object, the code keeps being re-inserted into the script associated with the combo box, even though there are now NO objects of popup menu type in my file at all! If I delete the code in xCode it will eventually come back when I make a change in IB.
What’s going on and how can I fix it?

This happens when in IB you still have an object linked to that action (‘on choose…’). My guess is that in your nib there is still a button somewhere where you have clicked the corresponding AppleScript action.

Actually, this is not quite the whole story. Yes, if there is another item attached to the handler, it will keep recreating the handler until there is nothing attached to it. BUT, it also happens when you’ve done what you describe, SuperMacGuy. If you simply delete an item in IB that is attached to a handler, it still has a reference to the applescript connection saved somewhere that is not reconciled. You may be able to quit IB and launch again to wipe clean that record. Try cleaning and rebuilding your project, too. A couple years ago, I had projects that never did seem to recover from this problem.

If you decide to delete objects from your interface, it is always good practice to undo everything you’ve done… preferably in the manner and order in which you created them. I always disconnect objects from all of their handlers before deleting them to avoid the problem you’ve encountered. I have a feeling that not disconnecting objects before deleting them may also be the cause of many projects lost to crashes and corrupted nib files.

Always code intelligently,