可能重复:
performSelector可能导致泄漏,因为它的选择是未知
我在非ARC这段代码中没有错误或警告的工作原理:
- (void)addTarget:(id)target action:(SEL)action forControlEvents:(UIControlEvents)controlEvents
{
// Only care about value changed controlEvent
_target = target;
_action = action;
}
- (void)setValue:(float)value
{
if (value > _maximumValue)
{
value = _maximumValue;
} else if (value < _minimumValue){
value = _minimumValue;
}
// Check range
if (value <= _maximumValue & value >= _minimumValue)
{
_value = value;
// Rotate knob to proper angle
rotation = [self calculateAngleForValue:_value];
// Rotate image
thumbImageView.transform = CGAffineTransformMakeRotation(rotation);
}
if (continuous)
{
[_target performSelector:_action withObject:self]; //warning here
}
}
然而,当我转换成投射到ARC,我得到这样的警告:
“执行选择可能会导致泄漏,因为它的选择是未知的。”
我将不胜感激就如何作出相应的修改我的代码的想法..