23#import <Foundation/Foundation.h>
25NS_ASSUME_NONNULL_BEGIN
30@protocol DownloaderDelegate <NSObject>
36- (void)downloaderProceed:(
id)downloader;
41- (void)downloaderFinished:(
id)downloader;
46- (void)downloaderError:(
id)downloader;
52@interface Downloader : NSObject <NSURLSessionDataDelegate>
62- (instancetype)initWithURL:(NSURL *)url delegate:(nullable
id<DownloaderDelegate>)delegate;
73- (instancetype)initWithURL:(NSURL *)url
74 postJsonData:(NSData *)jsonData
75 delegate:(nullable
id<DownloaderDelegate>)delegate;
86- (instancetype)initWithURL:(NSURL *)url
87 postData:(NSData *)postData
88 delegate:(nullable
id<DownloaderDelegate>)delegate;
149@property(nonatomic)
int tag;
A one-shot HTTP request that reports its result to a delegate.
Definition Downloader.h:52
void startDownloading()
Starts the request.
Definition Downloader.m:68
int tag
An integer tag the caller may attach to the request.
Definition Downloader.m:183
unsigned long long currentSize()
The total bytes downloaded so far.
Definition Downloader.m:148
void connectionCancel()
Cancels the current session task and clears it.
Definition Downloader.m:88
nullable NSDictionary * getDataInJSON()
The body the request returned, parsed as JSON.
Definition Downloader.m:170
float currentProgress()
The fraction of the expected total that has arrived.
Definition Downloader.m:153
nullable NSData * getData()
The body the request returned.
Definition Downloader.m:165
void cancel()
Abandons the request.
Definition Downloader.m:81