我在非 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 后,我收到以下警告:
“执行选择器可能会导致泄漏,因为它的选择器是未知的。”
我将不胜感激有关如何相应地修改我的代码的想法..