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.