Вопрос

I parse HTML Data from a Website with the help of the TFHppleElement. Now during the parsing in the for loop I want to update the progressView but it isn't working. Why?

My Code:

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];
}
Это было полезно?

Решение

I got working it by doing it like this. So it is parsing in the background and I can update the UI.

dispatch_async( dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
        for (...) {

        ...
        for (...) {

                for (...) {

                    ...
                }
        }
    }
});
Лицензировано под: CC-BY-SA с атрибуция
Не связан с StackOverflow
scroll top