How to block for NSSavePanel response
How to block for NSSavePanel response
- Subject: How to block for NSSavePanel response
- From: Bruce Truax <email@hidden>
- Date: Tue, 13 Jul 2004 10:47:03 -0400
In my application I want to use the NSSavePanel to obtain a path which I
will then use to copy a file from one location to another. Until I obtain
the path I need to pause execution of my current controller. The method is
in an NSDocumentController subclass. The code for the save method and the
savePanelDidEnd method located in my FileHandler (NSDocumentController
subclass) is shown below:
- (IBAction) saveLensLibraryTo:(id)sender
{
pathToLensLibrary = [self setPathToLensLibrary:nil];
[savePanel setRequiredFileType:@"AV"];
[savePanel setTitle:@"Create New Lens Library"];
[savePanel beginSheetForDirectory:nil
file:nil
modalForWindow:currentWindow
modalDelegate:self
didEndSelector:@selector(savePanelDidEnd:returnCode:contextInfo:)
contextInfo:nil];
}
- (void) savePanelDidEnd: (NSSavePanel *)savePanel
returnCode: (int)returnCode
contextInfo:(void *)x
{
//Make sure user pressed OK
if (returnCode == NSOKButton){
pathToLensLibrary = [savePanel filename];
}else{
pathToLensLibrary = [self setPathToLensLibrary:@"invalid"];
}
}
This code is called from my window controller as follows:
NSDocumentController *theDocController;
theDocController = [FileHandler sharedDocumentController];
[theDocController saveLensLibraryTo:self];
pathToLensLibrary = [theDocController pathToLensLibrary];
The problem is that the last line which gets the path value executes
immediately and does not wait for the save panel to finish because I assume
that the save panel executes in a separate thread. Is there any way to
block the execution of my calling method until the save panel ends?
--
____________________________________________________________
Bruce E. Truax email: email@hidden
Optical Engineering Consultant
Diffraction Limited Design LLC
388 Wedgewood Road voice: 860-276-0450
Southington, CT 06489 fax: 860-620-9026
http://www.dld-llc.com
_____________________________________________________________
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.