您建议的情况不会覆盖上一个操作,但会将第二个操作
添加到按钮,从而导致
调用ViewController.function1和ViewController.function2.
您需要先删除目标中的上一个操作,然后再使用添加新操作
button1.removeTarget(self,action:#selector(ViewController.function1),forControlEvents:.AllEvents)
或者在添加新操作之前删除所有先前的操作
button1.removeTarget(nil,action:nil,forControlEvents:.AllEvents)