Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 7 additions & 6 deletions FetchRequests/Sources/Controller/FetchedResultsController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -172,17 +172,18 @@ public struct FetchedResultsSection<FetchedObject: FetchableObject>: Equatable,
// MARK: - FetchedResultsController

func performOnMainThread(async: Bool = true, handler: @escaping @MainActor () -> Void) {
@MainActor(unsafe)
func unsafeHandler() {
handler()
}

if !Thread.isMainThread {
if async {
DispatchQueue.main.async(execute: handler)
} else {
DispatchQueue.main.sync(execute: handler)
DispatchQueue.main.sync(execute: unsafeHandler)
}
} else {
@MainActor(unsafe)
func unsafeHandler() {
handler()
}
unsafeHandler()
}
}
Expand Down Expand Up @@ -1361,7 +1362,7 @@ private class Weak<Element: AnyObject>: NSObject {
}

private struct AssociatedKeys {
static var context = "context"
static var context = 0
}

private extension FetchableObjectProtocol where Self: NSObject {
Expand Down
2 changes: 1 addition & 1 deletion FetchRequests/Tests/TestObject.swift
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
import Foundation
import FetchRequests

final class TestObject: NSObject {
final class TestObject: NSObject, @unchecked Sendable {
typealias RawData = JSON

@objc dynamic var id: String
Expand Down