tags:

views:

562

answers:

3

I'm working with a WebView. If I place this call in my -awakeFromNib:

[myWebView setMainFrameURL:@"http://www.google.com"];

I get the behavior I want. Google's homepage displays in my WebView. But, I need to set the main frame's URL in another method from a mutable array containing NSStrings.

This method call

[myWebView setMainFrameURL:[mutableArrayContainingNSStrings objectAtIndex:0]];

does not update the WebView. Do I need to tell the WebView to reload? I tried -setNeedsDisplay:YES and -reload to no avail.

A: 

Have you tried setting a breakpoint on your action method to check that both myWebView and [mutableArrayContainingNSStrings objectAtIndex:0] are pointing to the correct objects?

Marc Charbonneau
A: 

Several things

(1) I second Marc's comment in making sure that it is pointing at the correct objects

(2) It's been a while since I've dealt with WebKit directly but I know that it's possible you may have strings like "www.google.com" and strings like that won't work, you need "http://www.google.com" which you have in your first call to myWebView. Make sure all of your URL Strings are like this. It's the browser (Safari/Chrome/etc) that expands www.google.com out into http://www.google.com so that you can actually visit the site

If none of that works show the strings here so I can verify and run tests to see what's going on with the WebView

Colin Wheeler
A: 

I figured out the problem. The WebView is an IBOutlet. I was doing the method call that was giving me problems before -awakeFromNib. Moved that one line to -awakeFromNib and it's sorted now. Thanks for the input. +1 to my list of newbie posts.

jxpx777