From 9f2097d3b9b7c36477f018e6889f625cc5da8af6 Mon Sep 17 00:00:00 2001 From: Ever Blacks Date: Thu, 8 Dec 2016 14:26:59 +0800 Subject: [PATCH] Add exception handler --- KILabel/Source/KILabel.m | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/KILabel/Source/KILabel.m b/KILabel/Source/KILabel.m index b32b882..d4a64d1 100644 --- a/KILabel/Source/KILabel.m +++ b/KILabel/Source/KILabel.m @@ -881,6 +881,10 @@ + (NSString *)linkStringFromAttributedString:(NSAttributedString *)attrStr withR { // Check to see if there's a link attribute in the text, which will be our link text. If not // we'll use the string in the raw text. + if (range.location == NSNotFound || range.location >= attrStr.length) { + return @""; + } + id realURL = [attrStr attribute:NSLinkAttributeName atIndex:range.location effectiveRange:nil]; if (realURL == nil) {