0
我正在使用LRResty和NSXMLRequest来显示来自API的搜索结果。这里是我的代码如下所示:是否更快地解析主线程上的XML?为什么?
[[UIApplication sharedApplication] setNetworkActivityIndicatorVisible:YES];
[[LRResty client] get:searchEndpointURL withBlock:^(LRRestyResponse *response) {
//NSLog(@"Results:\n\n\n%@", [response asString]);
[[UIApplication sharedApplication] setNetworkActivityIndicatorVisible:NO];
NSXMLParser *parser = [[NSXMLParser alloc] initWithData:[response responseData]];
parser.delegate = self;
//TODO: Why does this work faster than running in the background?
[parser parse];
//[parser performSelectorInBackground:@selector(parse) withObject:nil]
}];
出于某种原因,我的搜索显示控制器更新更快,当我分析阻塞主线程比没有。
性能下降是否与解析器没有在主线程上运行有关?怎么会这样?