Sandboxed app & NSOpenPanel causes crashes

前端 未结 4 1869
梦谈多话
梦谈多话 2021-02-19 07:40

I am doing a simple file open panel in my Cocoa app. I enable entitlements and app sandboxing. But on OS X 10.9, when the app should open a dialog using NSOpenPanel

4条回答
  •  走了就别回头了
    2021-02-19 08:31

    In my case the problem for this error was calling [NSOpenPanel openPanel] on a thread that was not the main one. Encapsulating the whole thing inside a

    dispatch_async(dispatch_get_main_queue(), ^{
       NSSavePanel *saveAsPanel = [[NSSavePanel alloc] init];
       // ... bla bla...
     });
    

    solved the problem

提交回复
热议问题