, WebView , . -runMode:beforeDate WebView :
- (void) OpenURL:(const char *)_url
{
NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
[NSApplication sharedApplication];
[NSApp setDelegate:self];
NSString *url = [NSString stringWithUTF8String:_url];
NSLog(@"OpenURL: %@", url);
NSRect windowRect = NSMakeRect(10.0f, 10.0f, 800.0f, 600.0f);
NSWindow *window = [[NSWindow alloc] initWithContentRect:windowRect
styleMask:(NSResizableWindowMask|NSClosableWindowMask|NSTitledWindowMask)
backing:NSBackingStoreBuffered defer:NO];
[window setDelegate:self];
WebView *webview = [[WebView alloc] initWithFrame:windowRect
frameName:@"mainFrame"
groupName:nil];
[webview setFrameLoadDelegate:self];
[[webview mainFrame]
loadRequest:[NSURLRequest requestWithURL:[NSURL URLWithString:url]]];
[window setContentView:webview];
[window makeKeyAndOrderFront:nil];
NSModalSession session = [NSApp beginModalSessionForWindow:window];
_result = NSModalResponseContinue;
while (_result == NSModalResponseContinue) {
NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
_result = [NSApp runModalSession:session];
[[NSRunLoop currentRunLoop] runMode:NSDefaultRunLoopMode
beforeDate:[NSDate distantFuture]];
[self doSomeWork];
[pool drain];
}
[NSApp endModalSession:session];
[pool release];
}
[NSApp stopModal], [NSApp abortModal] [NSApp stopModalWithCode:yourReturnCode] - :
- (void)windowWillClose:(NSNotification *)notification
{
NSLog(@"windowWillClose");
[NSApp stopModal];
}
: