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).