I have a UIProgressBar which is updated in a HTML Parsing for loop. But it is not updating smoothly. I want it to show a smooth increase. I have tried to put in async_dispatch but then it didnt update at all. Here is my code:
- (void)viewDidLoad
{
[super viewDidLoad];
[self performSelectorOnMainThread:@selector(getWeeklyProgram) withObject:nil waitUntilDone:NO];
}
-(void)getWeeklyProgram
{
NSURL *programURL = [NSURL URLWithString:@"http://www.mostlifeclub.com/studyo-programlari/"];
NSData *programHtmlData = [NSData dataWithContentsOfURL:programURL];
TFHpple *programHTMLParser = [TFHpple hppleWithHTMLData:programHtmlData];
NSString *activitiewXpathQueryString = @"//div[@class='wpb_row vc_row-fluid prk_full_width prk_section parallaxed']/div[@class='prk_inner_block columns centered']/div[@class='vc_span12 wpb_column column_container']/div[@class='wpb_wrapper']/div[@class='wpb_tabs wpb_content_element']//div[@class='wpb_wrapper wpb_tour_tabs_wrapper ui-tabs vc_clearfix']/div[@class='wpb_tab ui-tabs-panel wpb_ui-tabs-hide vc_clearfix']";
NSArray *activityNodes = [programHTMLParser searchWithXPathQuery:activitiewXpathQueryString];
NSMutableArray *activities = [[NSMutableArray alloc] init];
//for each node
for (TFHppleElement *element in activityNodes)
{
currentProgressCount += 1;
@try
{
//Here I want to increase ProgressBar
[self increaseProgress:currentProgressCount :activityNodes.count];
}
@catch(NSException* ex)
{
}
}
}
-(void)increaseProgress:(int)currentLine:(int)totalLines {
progressView.progress = (CGFloat)currentLine / (CGFloat)totalLines;
if(progressView.progress >= 1.0f)
{
NSLog(@"bitti");
}
}