- Canceling NSSavePanel Hang App
Re: Canceling NSSavePanel Hang App
toggle quoted messageShow quoted text
My discovery seemed random and unsettling, so I kept digging. I will read the docs you’re referring to But a sheet does seem to do the trick. What’s weird is this code has worked for years, so it must be some changes to the SDK I am updating to.
On Apr 2, 2020, at 14:31, Sak Wathanasin <sw@...> wrote:
Took a guess and enabled sandbox and added read/write to user selected file and the hang went away. Is it true that I cannot make an unsandboxed app and uses the NSSavePanel? I know this is a data point of one, so I want to be careful what conclusions I draw… any thoughts?
No, I have a non-sandboxed app and it works fine. I think the problem is that you are using NSSavePanel:runModal. If you look in the doc'n, it says:
"This method invokes NSApplication's runModalForWindow ..."
If it's doing that, then you need to cancel the modal yourslef (as with any call of runModalForWindow). Try putting a
in your "else" clause.
However, it may be simpler to use a sheet modal:
if (result == NSFileHandlingPanelOKButton)
self.saveFileURL = [[panel URLs] objectAtIndex:0];
You can spin the writing to a file off to a separate thread if it takes a long time.
Hope this helps,
Join firstname.lastname@example.org to automatically receive all group messages.