所以我有一个程序,在发生 try/catch 块后,我需要一个模式窗口出现,以便用户可以做出特定选择,然后我希望程序继续运行。我不知道如何进行这项工作,并且我不断收到这些异常。
*** Assertion failure in -[NSApplication _commonBeginModalSessionForWindow:relativeToWindow:modalDelegate:didEndSelector:contextInfo:], /SourceCache/AppKit/AppKit-1187.34/AppKit.subproj/NSApplication.m:3920
Exception detected while handling key input.
Modal session requires modal window
我已将模态表配置为以两种不同的方式出现,第一种方式是通过按钮按下,第二种方式是在我的 try catch 块之后。当我通过直接链接到它的按钮按下使其显示时,Configure Game
它工作正常,但是当我通过另一种方法中的 try catch 块进行操作时,它会抛出上述所有异常。
//Method that opens the modal sheet
- (IBAction)configureGame:(id)sender
{
//Calls a webview for the user to go to a specific location
NSString *FGstarter = @"http://www.google.com";
NSURL *FGplayerUrl = [NSURL URLWithString:FGstarter];
[webView setMainFrameURL:[FGplayerUrl absoluteString]];
//Opens the Modal Sheet
[NSApp beginSheet:configureSheet modalForWindow:mainWindow
modalDelegate:self didEndSelector:NULL contextInfo:nil];
}
//Select Method to a Select button which also closes the Sheet
- (IBAction)select:(id)sender{
//sets a NSString Instance Var to the Current URL of the webView
currentPage = [webView stringByEvaluatingJavaScriptFromString:@"window.location.href"]);
//Closes the sheet
[NSApp endSheet:configureSheet];
}
-(NSMutableArray *)loadPlayer:(NSString *)name{
@try {
// Code here might cause exception that gets caught in the catch
}
@catch (NSException *exception) {
//When I call this function I get all the exceptions listed in the top of the post
[self configureGame:nil];
//Ideally here what would happen here is the modal sheet would pop up the user would hit the select button that calls the select method then the program continues running.
}
NSString *page = currentPage;
//...Continue Using this method
}