0

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

David Zorychta
  • 13,039
  • 6
  • 45
  • 81

1 Answers1

0

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

Wevah
  • 28,182
  • 7
  • 83
  • 72
  • If I don't call [savePanel runModal]; then my app no longer crashes, but I still get the message about a timeout having occurred. – David Zorychta Jul 21 '13 at 23:23