ahmetardal / SSCheckBoxView

SSCheckBoxView is a check box UI control for iOS apps.
Apache License 2.0
235 stars 64 forks source link

PerformSelector may cause a leak because its selector is unknown #2

Open Spokane-Dude opened 10 years ago

Spokane-Dude commented 10 years ago

Getting the above warning on this line of code in the touchesEnded method:

 [delegate performSelector: stateChangedSelector withObject:self];

I don't want to change anything just in case it causes more damage. I'm using XCode 5.1.

ahmetardal commented 10 years ago

It shouldn't do any harm if you set the delegate and the selector correctly.

Spokane-Dude commented 10 years ago

It's not in my code.. it's in your code; I'm afraid that it will become a build error in the not too distant future. Can you not correct it?

ahmetardal commented 10 years ago

Just use the state changed block, don't use the delegate then.

SSCheckBoxView *cbv = ...
[cbv setStateChangedBlock:^(SSCheckBoxView *v) {
    NSLog(@"checkbox state: %d", v.checked);
}];
Spokane-Dude commented 10 years ago

I think we're not talking about the same code... this is the code in your SSCheckedBoxView.m, method is: touchesEnded: withEvent:

    if (CGRectContainsPoint(validTouchArea, point)) {
        checked = !checked;
        [self updateCheckBoxImage];
        if (delegate && stateChangedSelector) {
            [delegate performSelector: stateChangedSelector withObject:self];  //  <----warning here
        }
        else if (stateChangedBlock) {
            stateChangedBlock(self);
        }
    }

The build warning is on the line indicated with <---warning here

ahmetardal commented 10 years ago

I'll update it when I've time. For now just use the block and don't set the delegate.