Apologies if this is not the right category to ask this question, I believe it is more related to Swift Concurrency than the use of AppKit.
I'm trying to convert some code to use the new async features of macOS 12 AppKit. I understand that generally an
await might suspend and resume on a different thread. However, I thought if the async function in which this
await occurs has been isolated to the
@MainActor, the continuation would always execute on the main thread. This is not the case with
await NSOpenPanel.begin(), which resumes on Queue : com.apple.root.user-initiated-qos.cooperative (concurrent).
Do I need to explicitly schedule the code after the
await to run on the MainActor again (e.g. using
MainActor.run) and being able to read the result from the
url property? That seems odd.
If I use the older-style completion handler API of
NSOpenPanel.begin(), the handler is executed on the main thread.
Many thanks for any insight.
(Using latest macOS 12 Beta, Xcode 13 beta 5)