Cocoa app crashes when trying to open a save dialog: Timeout occured while waiting for the window

StackOverflow https://stackoverflow.com/questions/17777116

  •  03-06-2022
  •  | 
  •  

문제

I wrote an HTML5 app and I'm making a wrapper for it in Cocoa for the Mac. I'm in the process of writing a method that will take a url and let the user save it to their disk. Here is the method so far:

- (void) downloadFile: (NSString *) url {

    NSSavePanel * savePanel = [NSSavePanel savePanel];
    [savePanel setAllowedFileTypes: @[@"png"]];
    [savePanel setNameFieldStringValue:@"test"];
    [savePanel beginWithCompletionHandler:^(NSInteger result){
        //NSArray * files = [[openDlg URLs] valueForKey: @"relativePath"];
        //[resultListener chooseFilenames: files]  ;
    }];
    [savePanel runModal];

}

However when I invoke the method (long after the window is made) my app crashes and I get this error in the console: 2013-07-21 18:23:05.067 Reditr[31458:d11f] RVS:__54-[NSRemoteSavePanel _runOrderingOperationWithContext:]_block_invoke_0319 : Timeout occured while waiting for the window

도움이 되었습니까?

해결책

You don't want to use both -runModal and -beginWithCompletionHandler:. Use one or the other (preferably the latter).

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top