From 5bdb8d317394ea1d53e173866e03adedbdfd680f Mon Sep 17 00:00:00 2001 From: Michael Haynes Date: Thu, 17 Oct 2013 17:18:40 +0100 Subject: [PATCH] Modified manger methods to return TCBlobDownload on start of new download as well as updated documentation --- README.md | 10 ++++++---- TCBlobDownload/TCBlobDownload/TCBlobDownloadManager.h | 4 ++-- TCBlobDownload/TCBlobDownload/TCBlobDownloadManager.m | 8 ++++++-- 3 files changed, 14 insertions(+), 8 deletions(-) diff --git a/README.md b/README.md index 22afab1e..8adca072 100644 --- a/README.md +++ b/README.md @@ -30,11 +30,11 @@ Requires **iOS 5.0 or later**. ## Methods #### TCBlobDownloadManager ```objective-c -- (void)startDownloadWithURL:(NSURL *)url +- (TCBlobDownload *)startDownloadWithURL:(NSURL *)url downloadPath:(NSString *)customPathOrNil andDelegate:(id)delegateOrNil; -- (void)startDownloadWithURL:(NSURL *)url +- (TCBlobDownload *)startDownloadWithURL:(NSURL *)url downloadPath:(NSString *)customPathOrNil firstResponse:(void (^)(NSURLResponse *response))firstResponseBlock progress:(void (^)(float receivedLength, float totalLength))progressBlock @@ -88,7 +88,8 @@ To immediately start a download in the default TCBlobDownloadManager directory ( #import "TCBlobDownloadManager.h" TCBlobDownloadManager *sharedManager = [TCBlobDownloadManager sharedDownloadManager]; -[sharedManager startDownloadWithURL:@"http://give.me/abigfile.avi" + +TCBlobDownload *downloader = [sharedManager startDownloadWithURL:@"http://give.me/abigfile.avi" downloadPath:nil firstResponse:^(NSURLResponse *response) { // [response expectedContentLength]? @@ -108,7 +109,8 @@ If you set a customPath: ```objective-c NSString *customPath = [NSTemporaryDirectory() stringByAppendingPathComponent:@"My/Custom/Path/"]; -[sharedManager addDownloadWithURL:@"http://give.me/abigfile.avi" + +TCBlobDownload *downloader = [sharedManager startDownloadWithURL:@"http://give.me/abigfile.avi" customPathOrNil:customPath // important andDelegate:nil]; ``` diff --git a/TCBlobDownload/TCBlobDownload/TCBlobDownloadManager.h b/TCBlobDownload/TCBlobDownload/TCBlobDownloadManager.h index 8c506966..5cd60e08 100644 --- a/TCBlobDownload/TCBlobDownload/TCBlobDownloadManager.h +++ b/TCBlobDownload/TCBlobDownload/TCBlobDownloadManager.h @@ -23,14 +23,14 @@ The download will be added to a NSOperationQueue and will run in background. */ -- (void)startDownloadWithURL:(NSURL *)url +- (TCBlobDownload *)startDownloadWithURL:(NSURL *)url customPath:(NSString *)customPathOrNil delegate:(id)delegateOrNil; /** Same but with completion blocks */ -- (void)startDownloadWithURL:(NSURL *)url +- (TCBlobDownload *)startDownloadWithURL:(NSURL *)url customPath:(NSString *)customPathOrNil firstResponse:(FirstResponseBlock)firstResponseBlock progress:(ProgressBlock)progressBlock diff --git a/TCBlobDownload/TCBlobDownload/TCBlobDownloadManager.m b/TCBlobDownload/TCBlobDownload/TCBlobDownloadManager.m index 09d9dca6..240ac402 100644 --- a/TCBlobDownload/TCBlobDownload/TCBlobDownloadManager.m +++ b/TCBlobDownload/TCBlobDownload/TCBlobDownloadManager.m @@ -71,7 +71,7 @@ - (NSUInteger)downloadCount #pragma mark - TCBlobDownloads Management -- (void)startDownloadWithURL:(NSURL *)url +- (TCBlobDownload *)startDownloadWithURL:(NSURL *)url customPath:(NSString *)customPathOrNil delegate:(id)delegateOrNil { @@ -84,9 +84,11 @@ - (void)startDownloadWithURL:(NSURL *)url downloadPath:downloadPath delegate:delegateOrNil]; [_operationQueue addOperation:downloader]; + + return downloader; } -- (void)startDownloadWithURL:(NSURL *)url +- (TCBlobDownload *)startDownloadWithURL:(NSURL *)url customPath:(NSString *)customPathOrNil firstResponse:(FirstResponseBlock)firstResponseBlock progress:(ProgressBlock)progressBlock @@ -105,6 +107,8 @@ - (void)startDownloadWithURL:(NSURL *)url error:errorBlock complete:completeBlock]; [self.operationQueue addOperation:downloader]; + + return downloader; } - (void)startDownload:(TCBlobDownload *)blobDownload