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

Fix crash when attribute NSLinkAttributeName is kind of NSString #772

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

xspyhack
Copy link

@xspyhack xspyhack commented Dec 28, 2017

TTTAttributedLabel does not handle NSLinkAttributeName attribute is kind of NSString, so it will use a NSString type value to init NSLinkCheckingResult by [NSTextCheckingResult linkCheckingResultWithRange:range URL:url]; // url is kind of NSString.

switch (result.resultType) {
    case NSTextCheckingTypeLink:
        if ([self.delegate respondsToSelector:@selector(attributedLabel:didSelectLinkWithURL:)]) {
            [self.delegate attributedLabel:self didSelectLinkWithURL:result.URL]; // the result.URL is kind of NSString, not NSURL
            return;
        }
        break;
#pragma mark - TTTAttributedLabelDelegate

- (void)attributedLabel:(TTTAttributedLabel *)label didSelectLinkWithURL:(NSURL *)url {
    // Crashed here when use url as `NSURL`.
}

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

Successfully merging this pull request may close these issues.

None yet

1 participant