JubeatPlus 3.9.11
Loading...
Searching...
No Matches
Downloader.h
Go to the documentation of this file.
1
22
23#import <Foundation/Foundation.h>
24
25NS_ASSUME_NONNULL_BEGIN
26
30@protocol DownloaderDelegate <NSObject>
31@optional
36- (void)downloaderProceed:(id)downloader;
41- (void)downloaderFinished:(id)downloader;
46- (void)downloaderError:(id)downloader;
47@end
48
52@interface Downloader : NSObject <NSURLSessionDataDelegate>
53
62- (instancetype)initWithURL:(NSURL *)url delegate:(nullable id<DownloaderDelegate>)delegate;
63
73- (instancetype)initWithURL:(NSURL *)url
74 postJsonData:(NSData *)jsonData
75 delegate:(nullable id<DownloaderDelegate>)delegate;
76
86- (instancetype)initWithURL:(NSURL *)url
87 postData:(NSData *)postData
88 delegate:(nullable id<DownloaderDelegate>)delegate;
89
97- (void)startDownloading;
98
105- (void)cancel;
106
111- (void)connectionCancel;
112
118- (unsigned long long)currentSize;
119
125- (float)currentProgress;
126
132- (nullable NSData *)getData;
133
143- (nullable NSDictionary *)getDataInJSON;
144
149@property(nonatomic) int tag;
150
151@end
152
153NS_ASSUME_NONNULL_END
154
155// code: language=Objective-C
156// kate: hl Objective-C;
157// vim: set ft=objc :
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