Skip to content

Commit 74a3090

Browse files
authored
Merge pull request #28 from HaysSoftware/feature/SkipRangeNotFound
makeInteractive Crash fix when NSRange.location == NSNotFound
2 parents ea62827 + cf551cf commit 74a3090

1 file changed

Lines changed: 1 addition & 0 deletions

File tree

Sources/Attributer.swift

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -565,6 +565,7 @@ open class Attributer {
565565
*/
566566
open func makeInteract(_ callback: @escaping ((_ link: String) -> ())) -> Attributer {
567567
for nsRange in self.ranges {
568+
guard nsRange.location != NSNotFound else { return self }
568569
let unEscapedString = (self.attributedText.string as NSString).substring(with: nsRange)
569570
let escapedString = unEscapedString.addingPercentEncoding(withAllowedCharacters: NSCharacterSet.urlHostAllowed) ?? ""
570571
self.attributedText.addAttribute(NSAttributedString.Key.link, value: "AttributedTextView:\(escapedString)", range: nsRange)

0 commit comments

Comments
 (0)