下载按钮放在UITableView中的所有单元格上。当我一次点击一次并等到完成下载时,我收到的文件很好,但是当我点击下载按钮上的2个或更多时,我收到的文件都混淆了。请有人帮助我。
- (void)connection:(NSURLConnection *)connection didReceiveData:(NSData *)data {
NSMutableDictionary *dict = [self getConnectionInfo:connection];
NSInteger bytes = [data length] + [[dict objectForKey:@"receivedBytes"] intValue];
[dict setObject:[NSNumber numberWithInt:bytes] forKey:@"receivedBytes"];
int row = [[dict objectForKey:@"row"] intValue];
NSIndexPath *indexPath = [NSIndexPath indexPathForRow:row inSection:0];
[self.aTableView reloadRowsAtIndexPaths:[NSArray arrayWithObject:indexPath]
withRowAnimation:UITableViewRowAnimationNone];
[myWebData appendData:data];
[dict setObject:myWebData forKey:@"myData"];
}
- (void)connectionDidFinishLoading:(NSURLConnection *)connection {
//Write file to folder
NSMutableDictionary *dict = [self getConnectionInfo:connection];
[self.activeConnections removeObject:dict];
NSString *fileName = [dict valueForKey:@"fName"];;
DLOAD_PATH = [NSString stringWithFormat:@"%@/%@",DLOAD_PATH0,fileName];
NSData *myData1 = [dict objectForKey:@"myData"];
[myData1 writeToFile:DLOAD_PATH atomically:YES];}
答案 0 :(得分:0)
答案 1 :(得分:0)
NSMutableData * myWebData1 =(NSMutableData *)[dict objectForKey:@“myMutData”];
[myWebData1 appendData:data];