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

Unrecognized selector crashes #13

Open
hpique opened this issue Feb 23, 2014 · 1 comment
Open

Unrecognized selector crashes #13

hpique opened this issue Feb 23, 2014 · 1 comment

Comments

@hpique
Copy link
Contributor

hpique commented Feb 23, 2014

I'm getting "unrecognized selector" crashes in PSPDFTextView.

-[PSPDFTextView scrollViewDidScroll:]: unrecognized selector sent to instance 0x1641f200

These started after implementing scrollViewDidScroll: in the PSPDFTextView/UITextView (real) delegate, a UIViewController. To reproduce, dealloc the UIViewController while still scrolling.

The stack trace:

screen shot 2014-02-23 at 00 53 00

Looks like it might be a delegate forwarding issue, but after looking at the code I'm not exactly sure what might be causing it.

If I add the following to PSPDFTextView the crashes disappear.

- (void)scrollViewDidScroll:(UIScrollView *)scrollView
{
    if ([_realDelegate respondsToSelector:@selector(scrollViewDidScroll:)])
    {
        [_realDelegate scrollViewDidScroll:scrollView];
    }
}

However, this is a patch that hides the real issue. Any idea of what it might be?

@derpoliuk
Copy link

It's not PSPDFTextView issue, it's Cocoa Touch bug (if we can call it this way).

I believe checking [delegate respondsToSelector:@selector(scrollViewDidScroll:)] every time UIScrollView scrolls affects performance. I've got same issue with UITableView. My fix:

- (void)dealloc {
    _tableView.delegate = nil;
}

So for you this fix will be set PSPDFTextView's delegate to nil in your UIViewController dealloc method.

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