【发布时间】:2012-03-23 17:07:38
【问题描述】:
我正在使用 LRResty 和 NSXMLRequest 来显示来自 API 的搜索结果。这是我的代码的样子:
[[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]
}];
由于某种原因,当我解析阻塞主线程时,我的搜索显示控制器更新比没有阻塞时更快。
性能变慢是否与解析器未在主线程上运行有关?怎么会这样?
【问题讨论】:
标签: objective-c multithreading performance nsxmlparser uisearchdisplaycontroller