From e056ff72edd80c7457b536a4012f0b44696383b0 Mon Sep 17 00:00:00 2001 From: Albert Schulz Date: Tue, 29 Apr 2014 09:41:55 +0200 Subject: [PATCH] previousTotal depending on single download thread --- .../xcshareddata/TCBlobDownloadExample.xccheckout | 14 +++++++------- TCBlobDownload/TCBlobDownload/TCBlobDownloader.m | 6 ++++-- 2 files changed, 11 insertions(+), 9 deletions(-) diff --git a/Example/TCBlobDownloadExample.xcodeproj/project.xcworkspace/xcshareddata/TCBlobDownloadExample.xccheckout b/Example/TCBlobDownloadExample.xcodeproj/project.xcworkspace/xcshareddata/TCBlobDownloadExample.xccheckout index b975d68a..04a9bd95 100644 --- a/Example/TCBlobDownloadExample.xcodeproj/project.xcworkspace/xcshareddata/TCBlobDownloadExample.xccheckout +++ b/Example/TCBlobDownloadExample.xcodeproj/project.xcworkspace/xcshareddata/TCBlobDownloadExample.xccheckout @@ -5,34 +5,34 @@ IDESourceControlProjectFavoriteDictionaryKey IDESourceControlProjectIdentifier - 88303317-EAAE-4C24-A97C-A502FC06B428 + F39411CF-86E8-472C-BB23-59E6E7BADCEC IDESourceControlProjectName TCBlobDownloadExample IDESourceControlProjectOriginsDictionary - B3681C98-7CEA-406E-BF79-4FBCE3FC3E82 - https://github.com/thibaultCha/TCBlobDownload + AAF2C7DA-26ED-4FFF-9AAA-45212BB1FAE3 + https://github.com/albertschulz/TCBlobDownload IDESourceControlProjectPath Example/TCBlobDownloadExample.xcodeproj/project.xcworkspace IDESourceControlProjectRelativeInstallPathDictionary - B3681C98-7CEA-406E-BF79-4FBCE3FC3E82 + AAF2C7DA-26ED-4FFF-9AAA-45212BB1FAE3 ../../.. IDESourceControlProjectURL - https://github.com/thibaultCha/TCBlobDownload + https://github.com/albertschulz/TCBlobDownload IDESourceControlProjectVersion 110 IDESourceControlProjectWCCIdentifier - B3681C98-7CEA-406E-BF79-4FBCE3FC3E82 + AAF2C7DA-26ED-4FFF-9AAA-45212BB1FAE3 IDESourceControlProjectWCConfigurations IDESourceControlRepositoryExtensionIdentifierKey public.vcs.git IDESourceControlWCCIdentifierKey - B3681C98-7CEA-406E-BF79-4FBCE3FC3E82 + AAF2C7DA-26ED-4FFF-9AAA-45212BB1FAE3 IDESourceControlWCCName TCBlobDownload diff --git a/TCBlobDownload/TCBlobDownload/TCBlobDownloader.m b/TCBlobDownload/TCBlobDownload/TCBlobDownloader.m index dacba5ea..db05479f 100644 --- a/TCBlobDownload/TCBlobDownload/TCBlobDownloader.m +++ b/TCBlobDownload/TCBlobDownload/TCBlobDownloader.m @@ -15,7 +15,9 @@ #import "TCBlobDownloader.h" #import "UIDevice-Hardware.h" -@interface TCBlobDownloader () +@interface TCBlobDownloader () { + uint64_t previousTotal; +} // Public @property (nonatomic, copy, readwrite) NSURL *downloadURL; @property (nonatomic, copy, readwrite) NSString *pathToFile; @@ -134,6 +136,7 @@ - (void)start [self.file seekToEndOfFile]; _receivedDataBuffer = [[NSMutableData alloc] init]; _samplesOfDownloadedBytes = [[NSMutableArray alloc] init]; + previousTotal = 0; _connection = [[NSURLConnection alloc] initWithRequest:fileRequest delegate:self startImmediately:NO]; @@ -354,7 +357,6 @@ - (void)updateTransferRate [self.samplesOfDownloadedBytes removeObjectAtIndex:0]; } - static uint64_t previousTotal; [self.samplesOfDownloadedBytes addObject:[NSNumber numberWithUnsignedLongLong:self.receivedDataLength - previousTotal]]; previousTotal = self.receivedDataLength; // Compute the speed rate on the average of the last seconds samples