diff --git a/Sources/Addons/Sharing/Activity/SharingActivityManager.swift b/Sources/Addons/Sharing/Activity/SharingActivityManager.swift index 7bc9dc4c..a2b5c7ce 100644 --- a/Sources/Addons/Sharing/Activity/SharingActivityManager.swift +++ b/Sources/Addons/Sharing/Activity/SharingActivityManager.swift @@ -1,34 +1,45 @@ #if canImport(UIKit) && os(iOS) import UIKit -@MainActor -internal final class SharingActivityManager: UIActivity, Sendable { +internal final class SharingActivityManager: UIActivity, @unchecked Sendable { internal override class var activityCategory: UIActivity.Category { Activity.category } - private var items: [SharingItem] = [] + private let accessQueue = DispatchQueue( + label: "SharingActivityManager \(UUID().uuidString)", + qos: .userInitiated, + attributes: .concurrent + ) + + private var _items: [SharingItem] = [] + private var items: [SharingItem] { + get { + accessQueue.sync { + _items + } + } + set { + accessQueue.async(flags: .barrier) { [weak self] in + self?._items = newValue + } + } + } internal let navigator: ScreenNavigator internal let activity: Activity internal override var activityType: UIActivity.ActivityType? { - MainActor.assumeIsolated { - activity.type - } + activity.type } internal override var activityTitle: String? { - MainActor.assumeIsolated { - activity.title - } + activity.title } internal override var activityImage: UIImage? { - MainActor.assumeIsolated { - activity.image - } + activity.image } internal override var activityViewController: UIViewController? { @@ -55,16 +66,12 @@ internal final class SharingActivityManager: UI internal override func canPerform(withActivityItems activityItems: [Any]) -> Bool { let activityItems = activityItems.map(SharingItem.init(activityItem:)) - return MainActor.assumeIsolated { - activity.isApplicable(for: activityItems) - } + return activity.isApplicable(for: activityItems) } internal override func prepare(withActivityItems activityItems: [Any]) { let activityItems = activityItems.map(SharingItem.init(activityItem:)) - MainActor.assumeIsolated { - items = activityItems - } + items = activityItems } internal override func perform() {