I need to remove an action from a object and then add a new one.
I've used this code to add the new action:
[Button addTarget:self action:@selector(newAction:) forControlEvents:UIControlEventTouchUpInside];
I've then tried to use this code to remove the old action:
[Button removeTarget:self action:@selector(oldAction:) forControlEvents:UIControlEventTouchUpInside];
The problem is that it somehow also removes the newAction.
Any ideas?
Thanks in advance :)
In that case, a simple solution is to instead remove the old action first before adding the new one. i.e. do it the other way around.
You can remove all actions by passing
nil
for target too.