这在主线程上工作正常,但由于某种原因在后台线程上运行时不起作用。如果您只是注释掉对 dispatch_async 的调用,那么程序就可以正常工作!
代码:
NSString *requestString = [NSString stringWithFormat:@"http://www.songlyrics.com/index.php?section=search&searchW=%@+%@&submit=Search",actualSongName,actualSongArtist];
NSLog(@"0");
TFHpple *requestParser = [TFHpple hppleWithHTMLData:[NSData dataWithContentsOfURL:[NSURL URLWithString:requestString]]];
NSLog(@"1");
NSString *requestedURLXPathQuery = @"//a";
NSArray *requestedStringsNodes = [requestParser searchWithXPathQuery:requestedURLXPathQuery];
NSLog(@"2");
这是记录的内容:
2012-10-11 21:39:05.636 SuperViewer[6612:110b] 0
2012-10-11 21:39:05.651 SuperViewer[6612:907] Unable to parse.
2012-10-11 21:39:06.520 SuperViewer[6612:110b] 1
2012-10-11 21:39:06.565 SuperViewer[6612:110b] 2
这一切都在后台线程上运行。我还记录了“requestString”变量及其罚款。
任何想法是什么问题?Hpple 不在后台线程上运行吗?
谢谢!