I load data from different links using ASIHTTPRequest and NSOperationQueue in
Download in the background. When the request is complete, I understand using requestFinished
delegate the ASIHTTPRequest method. I want to update data in tableview when all requests in
the queue is complete. Is there any way to find out when NSOperationQueue processed everything
inquiries? I mean, is there a variable in the queue like 'isEmpty' or any delegate method like 'queueDidCompletedAllOperation'?
Please, help.
Here is the code:
//source @interface SourceModel : NSObject @property (nonatomic, retain) NSString * link; @property (nonatomic, retain) NSString * name; @end //for rssGroup @interface CompleteRSSDataModel : NSObject @property (nonatomic,strong) SourceModel * source; @property (nonatomic,strong) KissXMLParser * parser; @property (nonatomic,strong) NSArray * rssArticles; @end - (void)viewDidLoad { for (int index=0; index<[rssGroups count]; index++) { NSString * urlString = [[[rssGroups objectAtIndex:index] source] link]; NSURL *url = [NSURL URLWithString:urlString]; ASIHTTPRequest *request = [ASIHTTPRequest requestWithURL:url]; [request setDelegate:self]; //set this request tag to group index of this source(link). See requestFinished for use of this :) [request setTag:index]; [self.queue addOperation:request]; } } - (void)requestFinished:(ASIHTTPRequest *)request { NSLog(@"%@",@"RSS Data got from internet successfully :))"); int groupIndex = [request tag]; CompleteRSSDataModel * group = [rssGroups objectAtIndex:groupIndex]; group.parser = [[KissXMLParser alloc]initWithData:[request responseData]]; if (group.parser == nil) { NSLog(@"%@",@"Failed - Error in parsing data :(("); } else { NSLog(@"%@",@"Data Parsed successfully :))"); group.rssArticles = [group.parser itemsInRss]; //So i want to check here that queue is empty, reload data, but as my information, i don't know any method like hasCompletedAllRequested //if(self.queue hasCompletedAllRequests) { // [self.tableview reloadData]; //} } } - (void)requestFailed:(ASIHTTPRequest *)request { NSLog(@"%@",@"Error in Getting RSS Data from internet:(("); }
source share