Skip to content

Commit

Permalink
Add some missing MainActor annotations
Browse files Browse the repository at this point in the history
  • Loading branch information
mattmassicotte committed Apr 6, 2024
1 parent 0e3eaad commit 1948245
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 4 deletions.
10 changes: 6 additions & 4 deletions Sources/Rearrange/UITextRange+Convenience.swift
@@ -1,8 +1,9 @@
#if os(iOS) || os(tvOS) || os(visionOS)
import UIKit

public extension NSRange {
init?(_ textRange: UITextRange, textView: UITextView) {
extension NSRange {
@MainActor
public init?(_ textRange: UITextRange, textView: UITextView) {
let location = textView.offset(from: textView.beginningOfDocument, to: textRange.start)
let length = textView.offset(from: textRange.start, to: textRange.end)

Expand All @@ -14,8 +15,9 @@ public extension NSRange {
}
}

public extension UITextView {
func textRange(with range: NSRange) -> UITextRange? {
extension UITextView {
@MainActor
public func textRange(with range: NSRange) -> UITextRange? {
guard let start = position(from: beginningOfDocument, offset: range.location) else {
return nil
}
Expand Down
2 changes: 2 additions & 0 deletions Tests/RearrangeTests/UITextRangeTests.swift
Expand Up @@ -4,6 +4,7 @@ import Rearrange
import UIKit

final class UITextRangeTests: XCTestCase {
@MainActor
func testTextRangeWithRange() throws {
let view = UITextView()

Expand All @@ -15,6 +16,7 @@ final class UITextRangeTests: XCTestCase {
XCTAssertEqual(textRange, fullRange)
}

@MainActor
func testRangeWithTextRange() throws {
let view = UITextView()

Expand Down

0 comments on commit 1948245

Please sign in to comment.