Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
if是否可以在带有 的语句中搜索字符串NSScanner?
if
NSScanner
我想搜索一个页面的html,然后如果有一段代码,做一些事情,如果没有,做其他事情......
谢谢!
您不需要使用NSScanner. 只需在 html 中搜索一个子字符串作为NSString. 像这样:
NSString
NSString *html = [webView stringByEvaluatingJavaScriptFromString: @"document.body.innerHTML"]; if ([html rangeOfString:@"some code here"].location!=NSNotFound) { //it exists in the web view }