From 04730482c6a7cedca8b2cdc0a378069199adaf4e Mon Sep 17 00:00:00 2001 From: dscyrescotti Date: Fri, 14 Oct 2022 11:24:15 +0630 Subject: [PATCH] fix: update text size in main thread to avoid thread warning --- Sources/AttributedText/TextSizeViewModel.swift | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/Sources/AttributedText/TextSizeViewModel.swift b/Sources/AttributedText/TextSizeViewModel.swift index 8f2dc62..5320bbd 100644 --- a/Sources/AttributedText/TextSizeViewModel.swift +++ b/Sources/AttributedText/TextSizeViewModel.swift @@ -4,6 +4,8 @@ final class TextSizeViewModel: ObservableObject { @Published var textSize: CGSize? func didUpdateTextView(_ textView: AttributedTextImpl.TextView) { - textSize = textView.intrinsicContentSize + DispatchQueue.main.async { [weak self] in + self?.textSize = textView.intrinsicContentSize + } } }