English | 中文
An powerful download library for iOS, macOS. Report an issue, Android use AndroidDownloader.
See iOSDemo for details.
See macOSDemo for details.
#import <CocoaDownloader/CocoaDownloader.h>
self.downloadManager=[DownloadManager sharedInstance];
Or detailed configuration.
//Custom config
DownloadConfig *config=[[DownloadConfig alloc] init];
//Download task number
config.downloadTaskNumber=2;
self.downloadManager=[DownloadManager sharedInstance:config];
//save path
NSString *documentPath=[NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES) lastObject];
NSString *path=[documentPath stringByAppendingPathComponent:@"IxueaCocoaDownloader/a.apk"];
NSLog(@"ixuea download save path:%@",path);
//Create download info.
self.downloadInfo=[[DownloadInfo alloc] init];
//Set download save path.
[self.downloadInfo setPath:path];
//Set download url.
[self.downloadInfo setUri:DEFAULT_URL];
//Set download info id.
[self.downloadInfo setId:DEFAULT_ID];
NSDate *date = [NSDate dateWithTimeIntervalSinceNow:0];
NSTimeInterval currentTimeMillis=[date timeIntervalSince1970];
//Set download create time.
[self.downloadInfo setCreatedAt:currentTimeMillis];
//Set download callcabk.
[self.downloadInfo setDownloadBlock:^(DownloadInfo * _Nonnull downloadInfo) {
//TODO Progress, status changes are callbacks.
}];
//Start download.
[self.downloadManager download:self.downloadInfo];
See SampleController for details.
See the example code, iOS and macOS platform downloaders use the same API.
Smile - @ixueadev on GitHub, Email is [email protected], See more ixuea(http://www.ixuea.com)
iOS & macOS QQ development group: 965841894.