2015-11-19 00:20:09 +00:00
|
|
|
#import <Foundation/Foundation.h>
|
|
|
|
|
2015-11-23 16:29:25 +00:00
|
|
|
typedef void (^DownloaderCallback)(NSNumber*, NSNumber*);
|
2015-11-19 00:20:09 +00:00
|
|
|
typedef void (^ErrorCallback)(NSError*);
|
2015-11-23 16:29:25 +00:00
|
|
|
typedef void (^BeginCallback)(NSNumber*, NSNumber*, NSDictionary*);
|
|
|
|
typedef void (^ProgressCallback)(NSNumber*, NSNumber*);
|
|
|
|
|
|
|
|
@interface DownloadParams : NSObject
|
|
|
|
|
|
|
|
@property (copy) NSString* fromUrl;
|
|
|
|
@property (copy) NSString* toFile;
|
|
|
|
@property (copy) DownloaderCallback callback; // Download has finished (data written)
|
|
|
|
@property (copy) ErrorCallback errorCallback; // Something went wrong
|
|
|
|
@property (copy) BeginCallback beginCallback; // Download has started (headers received)
|
|
|
|
@property (copy) ProgressCallback progressCallback; // Download is progressing
|
|
|
|
|
|
|
|
@end
|
2015-11-19 00:20:09 +00:00
|
|
|
|
|
|
|
@interface Downloader : NSObject <NSURLConnectionDelegate>
|
|
|
|
|
2015-11-23 16:29:25 +00:00
|
|
|
- (void)downloadFile:(DownloadParams*)params;
|
|
|
|
- (void)stopDownload;
|
2015-11-19 00:20:09 +00:00
|
|
|
|
|
|
|
@end
|