I fixed the error in the actor by using this code: private var backgroundCompletionHandler: (() async -> Void)? and func getBackgroundCompletionHandler() -> ((() async -> Void)?) { return backgroundCompletionHandler } func setBackgroundCompletionHandler(_ h: (() -> Void)?){ backgroundCompletionHandler=h } func executeCompletionHandler() async{ await backgroundCompletionHandler?() } Yet my error on the app delegate at: func application( _ application: UIApplication, handleEventsForBackgroundURLSession identifier: String, completionHandler: @escaping () -> Void) { let runCompletionHandler = {@MainActor in completionHandler() } Task.init{ await GeoreferenceQueue.shared.setBackgroundCompletionHandler(runCompletionHandler) } } Converting function value of type '@MainActor @Sendable () -> Void' to '() -> Void' loses global actor 'MainActor' is still there. Now I set all functions in the actor to MainActor as well the variable storing the completion: @MainActor private var backgroundCom
Topic:
Programming Languages
SubTopic:
Swift
Tags: