0

I have two webView, in the first i load an hostname and, when webViewDidFinishLoad i take a part of current url with this method:

//Method that take a part of currentUrl of a webView
   - (NSString *) webViewGetLocation {
   NSString *html = [dnsWebView stringByEvaluatingJavaScriptFromString:@"document.body.innerHTML"];

   if ([html rangeOfString:@"Account"].location != NSNotFound) {
      //Take loaded ip
      NSString *currentURL = [dnsWebView stringByEvaluatingJavaScriptFromString:@"window.location.href"];
      NSLog(@"IP TAKEN: %@", currentURL);

      //Do substring to find part of ip, until the port
      NSString *ip = [[self splitString: currentURL key: @"/login"] objectAtIndex: 0];
      NSLog(@"IP AND PORT: %@", ip);
   }
   return ip;
}

and at this time all ok.

Now in the second webView, i load an url that should be composed by the ip, that i take in previous method, and a second part that not change.

My problem is: how can i take that url (return ip), since i have launched method "webViewGetLocation" in method "webViewDidFinishLoad" that do not have a return value???

- (void)webViewDidFinishLoad:(UIWebView *)webView {
   [self webViewGetLocation];
}

I try to save returned ip of method "webViewGetLocation" in an appDelegate variable, but in viewDidLoad it is empty.

debug86
  • 1
  • 1
  • 1

2 Answers2

0

Thats easy, create a class property of type NSURL in your .h file Then set it in - (void)webViewDidFinishLoad:(UIWebView *)webView { NSURL *url = [NSURL URLWithString:@"folder/file.html" relativeToURL:baseURL];

Denis Kohl
  • 739
  • 8
  • 13
0

It's possible, in the same class, call method "webViewDidFinishLoad" more times, one for each webview for example???

debug86
  • 1
  • 1
  • 1