Skip to content

Commit

Permalink
Merge pull request #5 from mjphaynes/master
Browse files Browse the repository at this point in the history
TCBlobDownloadManager methods now return the instantiated TCBlobDownload
  • Loading branch information
thibaultcha committed Oct 17, 2013
2 parents d94b15a + e095040 commit 79aa145
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 8 deletions.
10 changes: 6 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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<TCBlobDownloadDelegate>)delegateOrNil;

- (void)startDownloadWithURL:(NSURL *)url
- (TCBlobDownload *)startDownloadWithURL:(NSURL *)url
downloadPath:(NSString *)customPathOrNil
firstResponse:(void (^)(NSURLResponse *response))firstResponseBlock
progress:(void (^)(float receivedLength, float totalLength))progressBlock
Expand Down Expand Up @@ -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]?
Expand All @@ -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];
```
Expand Down
4 changes: 2 additions & 2 deletions TCBlobDownload/TCBlobDownload/TCBlobDownloadManager.h
Original file line number Diff line number Diff line change
Expand Up @@ -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<TCBlobDownloadDelegate>)delegateOrNil;

/**
Same but with completion blocks
*/
- (void)startDownloadWithURL:(NSURL *)url
- (TCBlobDownload *)startDownloadWithURL:(NSURL *)url
customPath:(NSString *)customPathOrNil
firstResponse:(FirstResponseBlock)firstResponseBlock
progress:(ProgressBlock)progressBlock
Expand Down
8 changes: 6 additions & 2 deletions TCBlobDownload/TCBlobDownload/TCBlobDownloadManager.m
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ - (NSUInteger)downloadCount
#pragma mark - TCBlobDownloads Management


- (void)startDownloadWithURL:(NSURL *)url
- (TCBlobDownload *)startDownloadWithURL:(NSURL *)url
customPath:(NSString *)customPathOrNil
delegate:(id<TCBlobDownloadDelegate>)delegateOrNil
{
Expand All @@ -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
Expand All @@ -105,6 +107,8 @@ - (void)startDownloadWithURL:(NSURL *)url
error:errorBlock
complete:completeBlock];
[self.operationQueue addOperation:downloader];

return downloader;
}

- (void)startDownload:(TCBlobDownload *)blobDownload
Expand Down

0 comments on commit 79aa145

Please sign in to comment.