Re: [SOLVED!] Progress Sheet on a NSDocument
Re: [SOLVED!] Progress Sheet on a NSDocument
- Subject: Re: [SOLVED!] Progress Sheet on a NSDocument
- From: Kevin Hoctor <email@hidden>
- Date: Mon, 26 Mar 2007 12:13:51 -0500
On Mar 25, 2007, at 11:30 AM, Alan Smith wrote:
No, I didn't start it from a thread other than the main one unless a
menu item action is called from another thread.
Alan,
I had my program using a threaded scenario just like you are doing,
but I found that I didn't want the user to do anything in my program
until my import was done anyway so with the help of this group, I
changed my code to stay in the same thread:
- (IBAction)importQIF:(id)sender
{
NSOpenPanel *panel = [NSOpenPanel openPanel];
NSArray *fileTypes = [NSArray arrayWithObject:@"qif"];
[panel beginSheetForDirectory:nil file:nil types:fileTypes
modalForWindow:[self windowForSheet] modalDelegate:self
didEndSelector:@selector(openPanelDidEnd:returnCode:contextInfo:)
contextInfo:NULL];
}
- (void)openPanelDidEnd:(NSOpenPanel *)openPanel returnCode:(int)
returnCode contextInfo:(void *)contextInfo
{
[openPanel close];
if (returnCode != NSOKButton) return;
[NSApp beginSheet:progressPanel modalForWindow:[self windowForSheet]
modalDelegate:self didEndSelector:nil contextInfo:NULL];
NSModalSession modalSession = [NSApp
beginModalSessionForWindow:progressPanel];
[self importQIFUsingFile:[openPanel filename]
inModalSession:modalSession];
[NSApp endModalSession:modalSession];
[NSApp endSheet:progressPanel];
[progressPanel close];
}
The NSModalSession removed some quirky threading issues that popped
up every nth run of this process. You may not have any problems, but
if you do this is an alternative.
Peace,
Kevin Hoctor
email@hidden
No Thirst Software LLC
http://nothirst.com
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden