views:

26

answers:

1

I have added multiple target-action-forControlEvents: to a UIButton. I'd like to remove all of these in one go without deallocating anything. I will then set new targets.

Is this possible and how do I go about it?

+1  A: 

Call removeTarget:action:forControlEvents: pass nil for the target, NULL for action, and use a control mask that sets all bits (UIControlEventAllEvents). Something like this:

[someControl removeTarget:nil 
                   action:NULL 
         forControlEvents:UIControlEventAllEvents]; 
progrmr
Thanks for the tip! Here's the full link I think (ie. to the section): "http://developer.apple.com/iphone/library/documentation/uikit/reference/UIControl_Class/Reference/Reference.html#//apple_ref/occ/instm/UIControl/removeTarget:action:forControlEvents:"
SpecialK
progrmr's suggestion works of course. To add to the answer here is a code snippet like the one I needed:[button removeTarget:nil action:NULL forControlEvents:UIControlEventTouchUpInside];
SpecialK
I tried about 10 times to edit this last night but SO kept giving me the fail whale ;-)
progrmr
Aside: the -allTargets instance method returns an NSSet of all the instance's targets (nil if none).
SpecialK