Question

Is it possible to search for a string in an if statement with an NSScanner?

I wanted to search through the html of a page and then if there is a certain piece of code, do something and if not, do something else...

Thanks!

Was it helpful?

Solution

You don't need to use a NSScanner. Just search for a substring in the html as a NSString. Like so:

NSString *html = [webView stringByEvaluatingJavaScriptFromString: 
                                         @"document.body.innerHTML"];

if ([html rangeOfString:@"some code here"].location!=NSNotFound) {
    //it exists in the web view
}
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top