Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
Spokane-Dude opened this issue Apr 5, 2014 · 5 comments
Open

Comments

@Spokane-Dude
Copy link

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
Copy link
Owner

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

@Spokane-Dude
Copy link
Author

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
Copy link
Owner

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
Copy link
Author

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
Copy link
Owner

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants