Changing control state before executing code

I’m attempting to implement a feature whereby checking off an item in a table view will remove it from the table and transfer it to another data source. This works fine, except that the code that deletes the task (in an on clicked handler when the checkbox is clicked) is executed before the checkbox is toggled. This results in the item being deleted, but the state of the checkbox of the item following it being toggled. I’ve tried calling another handler when the checkbox is clicked, but it still waits for that script to be run before toggling the checkbox. Calling “performClick:” on a hidden button in the on clicked handler doesn’t work either, and neither does connecting the checkbox cell directly to a hidden button in Interface Builder.

In short, is there any way to either convince it to change the state of the checkbox and then execute the script, or, alternatively, toggle the state of the checkbox of the next data row so that it will be changed back when the row the user toggled is deleted? Any and all help is greatly appreciated.