我在TFHppleElement的帮助下从网站解析HTML数据。现在在for循环中解析期间我想更新progressView但它无法正常工作。为什么呢?
我的代码:
ParseHTMLData.m
for (...) {
...
for (...) {
for (...) {
...
}
}
SecondViewController *svc = [[SecondViewController alloc] init];
float prog = 0.9f; //For testing a fix value
[svc setProgressAnimated:[NSNumber numberWithFloat:prog]];
}
SecondViewController.m
-(void)setProgressAnimated: (NSNumber *)number;
{
[self.progressView setProgress:[number floatValue] animated:YES];
}
答案 0 :(得分:0)
我是这样做的。所以它在后台进行解析,我可以更新UI。
dispatch_async( dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
for (...) {
...
for (...) {
for (...) {
...
}
}
}
});