Fix crash when attribute NSLinkAttributeName is kind of NSString by xspyhack · Pull Request #772 · TTTAttributedLabel/TTTAttributedLabel · GitHub
Skip to content

Fix crash when attribute NSLinkAttributeName is kind of NSString#772

Open
xspyhack wants to merge 1 commit into
TTTAttributedLabel:masterfrom
xspyhack:master
Open

Fix crash when attribute NSLinkAttributeName is kind of NSString#772
xspyhack wants to merge 1 commit into
TTTAttributedLabel:masterfrom
xspyhack:master

Conversation

@xspyhack

@xspyhack xspyhack commented Dec 28, 2017

Copy link
Copy Markdown

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.

1 participant