Permalink
Find file
Fetching contributors…
Cannot retrieve contributors at this time
32 lines (26 sloc) 941 Bytes
//
// UIControl+SSToolkitAdditions.m
// SSToolkit
//
// Created by Sam Soffes on 4/19/10.
// Copyright 2010-2011 Sam Soffes. All rights reserved.
//
#import "UIControl+SSToolkitAdditions.h"
@implementation UIControl (SSToolkitAdditions)
- (void)removeAllTargets {
[[self allTargets] enumerateObjectsUsingBlock:^(id object, BOOL *stop) {
[self removeTarget:object action:NULL forControlEvents:UIControlEventAllEvents];
}];
}
- (void)setTarget:(id)target action:(SEL)action forControlEvents:(UIControlEvents)controlEvents
{
NSSet *targets = [self allTargets];
for (id currentTarget in targets) {
NSArray *actions = [self actionsForTarget:currentTarget forControlEvent:controlEvents];
for (NSString *currentAction in actions) {
[self removeTarget:currentTarget action:NSSelectorFromString(currentAction) forControlEvents:controlEvents];
}
}
[self addTarget:target action:action forControlEvents:controlEvents];
}
@end