From fef9d20515c7519cd81d6c596b6a566c2352a72f Mon Sep 17 00:00:00 2001 From: sakmt Date: Tue, 18 Sep 2018 15:08:28 +0900 Subject: [PATCH 1/2] fix: emoji annoys string.count --- RegeributedTextView/Classes/StringExt.swift | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/RegeributedTextView/Classes/StringExt.swift b/RegeributedTextView/Classes/StringExt.swift index f464953..fe1ef5d 100644 --- a/RegeributedTextView/Classes/StringExt.swift +++ b/RegeributedTextView/Classes/StringExt.swift @@ -23,7 +23,7 @@ extension String { // Returns matched range list by regular expression. func matched(by regex: String) -> [Range] { let result = try? NSRegularExpression(pattern: regex, options: []) - .matches(in: self, options: [], range: NSRange(location: 0, length: self.count)) + .matches(in: self, options: [], range: NSRange(location: 0, length: self.utf16.count)) .flatMap{ $0.range(at: 0).range(for: self) } return result ?? [] } From af9c19df4fecf7a6a9a53789791b49447df33fdd Mon Sep 17 00:00:00 2001 From: Takehiko Sakamoto Date: Mon, 12 Nov 2018 18:07:01 +0900 Subject: [PATCH 2/2] Fix: make delegate weak --- RegeributedTextView/Classes/RegeributedTextView.swift | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/RegeributedTextView/Classes/RegeributedTextView.swift b/RegeributedTextView/Classes/RegeributedTextView.swift index a1d28c0..24c80b3 100644 --- a/RegeributedTextView/Classes/RegeributedTextView.swift +++ b/RegeributedTextView/Classes/RegeributedTextView.swift @@ -150,7 +150,7 @@ open class RegeributedTextView: UITextView { fileprivate var tapAttributedTextGesture: UITapGestureRecognizer? - private var _delegate: RegeributedTextViewDelegate? + private weak var _delegate: RegeributedTextViewDelegate? private var attributedRanges: [AttributedRange] = [] { didSet {