Mailing Lists: Apple Mailing Lists

Image of Mac OS face in stamp
 
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

WebView question



I have a window with a WebView in it. When the app loads I can tell it's controller to load it and open a url in applicationDidFinishLaunching.

Works fine. I can change to that window any time and click links etc. but I don't want to open this window at launch time. The app is a sort of wizard that goes through steps and has a few threads doing things like connecting to http and ftp servers. When the steps are complete, I want to pop up the window with the WebView and tell it to load a specific URL that might not be known until right before it's needed to load. When I try to load a URL later -- one that works fine when done in applicationDidFinishLaunching -- nothing happens. I don't get an exception.

When I try opening a URL from another thread it also fails quietly. Something is wrong with the way I want to load it. Do you have to make calls to webkit from the main thread ?

Here's the only method from my controller object (NSWindowController subclass) I have to open a URL:

- (void) loadWebPage:(NSString *)page
{
[[myWebView mainFrame] loadRequest: [NSURLRequest requestWithURL: [NSURL URLWithString: page]]];
NSLog(@"Loading %@", page);
} // loadWebPage


I call loadWebPage from a thread like so:

- (void) showWebPage:(id) object
{
	NSAutoreleasePool*	pool = [[NSAutoreleasePool alloc] init];

browserController = [[WebController alloc] initWithWindowNibName: @"WebView"];
[browserController showWindow: self];
[browserController loadWebPage: [settings objectForKey: @"postDeliveryBrowserPage"]];

while(! userCanceled)
{
[NSThread sleepUntilDate:[NSDate dateWithTimeIntervalSinceNow: 0.2]]; // sleep a little
}


	[pool release];
} // showWebPage

And finally from applicationDidFinishLaunching I launch the thread like this:
[NSThread detachNewThreadSelector:@selector(showWebPage:) toTarget:self withObject:nil];



Any ideas about what I'm doing wrong ?

Thanks,
Matt
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/email@hidden

This email sent to email@hidden


Visit the Apple Store online or at retail locations.
1-800-MY-APPLE

Contact Apple | Terms of Use | Privacy Policy

Copyright © 2007 Apple Inc. All rights reserved.