1
我使用asihttprequest下载多个文件,我想知道如何在下载完成后使用正确的请求删除关联的UIProgressview。如何使用正确的请求删除关联的UIProgressview?
NSMutableArray *contentArray
包含ASIHTTPRequest
和NSMutableArray *progArray
包含我的自定义UIProgressview。
-(void)addDownload:(NSString *)theURL withName:(NSString *)fileName
{
theProgress = [[PDColoredProgressView alloc] initWithFrame:CGRectMake(3, 17, 314, 14)];
//...
ASIHTTPRequest *request = [ASIHTTPRequest requestWithURL:[NSURL URLWithString:theURL]];
//..
[request setDelegate:self];
[request setDownloadProgressDelegate:theProgress];
request.allowResumeForFileDownloads = YES;
[request startAsynchronous];
[request setShouldContinueWhenAppEntersBackground:YES];
[contentArray addObject:request];
[progArray addObject:theProgress];
[theProgress retain];
[self.tableView reloadData];
}
- (void)requestFinished:(ASIHTTPRequest *)request{
[contentArray removeObject:request];
[progArray removeObject:theProgress];
NSLog(@"%@",progArray);
NSLog(@"%@",contentArray);
[self reloadMyData];
[self.tableView reloadData];
}
的问题是,这个代码删除最后一个progressview即使有3周下载量contentArray
,第二个完成第一。 你能帮我吗?