Post

Replies

Boosts

Views

Activity

Reply to [General] -[NSAlert runModal] may not be invoked inside of transaction begin/commit pair
I have the same error with this simple code : DispatchQueue.global().async { // some code DispatchQueue.main.async { // some code NSAlert.init(error: ...... ).runModal() } } The answer given by the apple employee here https://developer.apple.com/forums/thread/88825 do not fix the problem. I am using Xcode 13.3 with macOS 12.3
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Replies
Boosts
Views
Activity
Apr ’22
Reply to [General] -[NSAlert runModal] may not be invoked inside of transaction begin/commit pair
Hello, I found a solution to workaround that bug : call runModal() in a function called from perform(#selector...) like this : @objc func displayAlert(error: NSError) { NSAlert.init(error: error).runModal() } self.perform(#selector(self.displayAlert), with: NSError, afterDelay: 0.3, inModes: [RunLoop.Mode.common]) Hope this will help you.
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Replies
Boosts
Views
Activity
Apr ’22
Reply to [General] -[NSAlert runModal] may not be invoked inside of transaction begin/commit pair
DispatchQueue asyncAfter do the trick too DispatchQueue.main.asyncAfter(deadline: .now() + 0.3, execute: { NSAlert.init(error: ...... ).runModal() } Seems the problem is in the delay.
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Replies
Boosts
Views
Activity
Apr ’22