Giter Club home page Giter Club logo

mzdownloadmanager's People

Contributors

alecgorge avatar farktronix avatar mzeeshanid avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

mzdownloadmanager's Issues

Tracking download model with optional extra param

@mzeeshanid MZDownloadModel should have an extra public optional variable so that i will be easy to track what is being downloaded.

open class MZDownloadModel {
open var optionalData:Any?
}

public func addDownloadTask(_ fileName: String, fileURL: String, destinationPath: String, andOptionalData optionalData:Any?)

I am facing issue to distinguish my downloads (without using url) :-(

Cocoapods

Would you consider adding a Podspec so that the library could be easily integrated in a project via cocoa pods?

How to get the name of downloaded file(eg.:suggestedFilename)

I download a file by a temp URL and no filename.

I note that user can get filename when dowload file with URLSession:

  • (NSURLSessionDownloadTask *)downloadTaskWithRequest:(NSURLRequest *)request completionHandler:(void (^)(NSURL * _Nullable location, NSURLResponse * _Nullable response, NSError * _Nullable error))completionHandler;

There is a property named 'suggestedFilename'.

Can i get something as suggestedFilename in MZDownloadManager?

Dropped support for iOS 8?

I noticed on your commit on November that your changed support from iOS 8 to iOS 9.

Can you share why or what would need to be done on a fork to continue supporting iOS 8? unfortunately I was using this on an enterprise app and they need to continue supporting iOS 8 who know why...

Thank you

Plagiarism

This is a copy of my downloading framework: https://github.com/H2CO3/HCDownload

You removed all copyright and licensing information, renamed the class and you pretend this is entirely your own intellectual property, whereas it isn't.

Download Progress showing incorrect values

Hi,

I'm getting random progress values for some downloads. For example one download start at progress value -12288.0 and ended at 304106.0, most of the time it works as expected.

Any ideas?

Bunch of downloads tracking

Hi guys, what if I need to download a bunch of files? I don't know how many files I have to download, it depends on the server, but I'd like to be able to track the download of every single file understanding when it finished. Is it possible? For example, adding a whole array of urls and not one by one maybe.. do you have some suggestion?

Crash MZDownloadManager.swift line 180

looks like this happends when the user press the home button and opens the app after a few minutes again.

specialized MZDownloadManager.(URLSession(URLSession, downloadTask : URLSessionDownloadTask, didWriteData : Int64, t

Crashed: com.apple.main-thread 0 MZDownloadManager 0x1010e8538 specialized MZDownloadManager.(URLSession(URLSession, downloadTask : URLSessionDownloadTask, didWriteData : Int64, totalBytesWritten : Int64, totalBytesExpectedToWrite : Int64) -> ()).(closure #1) (MZDownloadManager.swift:180) 1 MZDownloadManager 0x1010ec1fc partial apply for MZDownloadManager.(URLSession(URLSession, downloadTask : URLSessionDownloadTask, didWriteData : Int64, totalBytesWritten : Int64, totalBytesExpectedToWrite : Int64) -> ()).(closure #1) (MZDownloadManager.swift) 2 libdispatch.dylib 0x1804fe9e0 _dispatch_call_block_and_release + 24 3 libdispatch.dylib 0x1804fe9a0 _dispatch_client_callout + 16 4 libdispatch.dylib 0x1805035e8 _dispatch_main_queue_callback_4CF + 996 5 CoreFoundation 0x1815f50c8 __CFRUNLOOP_IS_SERVICING_THE_MAIN_DISPATCH_QUEUE__ + 12 6 CoreFoundation 0x1815f2ce4 __CFRunLoopRun + 1572 7 CoreFoundation 0x181522da4 CFRunLoopRunSpecific + 424 8 GraphicsServices 0x182f8c074 GSEventRunModal + 100 9 UIKit 0x1877dd058 UIApplicationMain + 208

progress view not updating view controller

so im using your demo with the same implementation the only difference is im not using tabbar im using viewControllers with segue the first view has the urls and the second view has the download cell when the download start everything work great but when get back to the url view and go to the download view again the progress bar stop updating and get back to it original state but i can tell that downloadCell.updateCellForRowAtIndexPath(indexPath, downloadModel: downloadModel) still working but not updating the progress

kill app and resume download

Hello,
i have this scenario (in example app):

  • close the application by tapping home button and swipe out the application
  • reopen application
  • i see this scenario:
    img_1518
    There is a way to avoid this?
    thank you
    Andrea

Project Not Building

Hi, Zeeshan

you did a great work, when i used your sample project it worked for me, but when i install it from cocoapods into my project it shows 79 issues on build time see the following issue

http://imgur.com/a/SuhAd

regards,
Naveed

Lots of crashes

Hi,

i have a lot of crashes like:

function signature specialization <Arg[0] = Owned To Guaranteed, Arg[1] = Owned To Guaranteed, Arg[4] = Owned To Guaranteed> of MZDownloadManager.MZDownloadManager.(URLSession (__ObjC.URLSession, downloadTask : __ObjC.URLSessionDownloadTask, didWriteData : Swift.Int64, totalBytesWritten : Swift.Int64, totalBytesExpectedToWrite : Swift.Int64) -> ()).(closure #1) (MZDownloadManager.swift:194)

don'n know how to fix this or you may fix this.

help , Initialize MZDownloadManagerViewController

how can i Initialize MZDownloadManagerViewController
im not using tabbar
i try
UINavigationController *mzDownloadingNav = [self.navigationController.viewControllers objectAtIndex: [self.navigationController.viewControllers count]-1];

mzDownloadingViewObj = [mzDownloadingNav.viewControllers objectAtIndex:0] ;

but it didnt work

Not Resuming

hey,I refer your idea to write a download manager, but does not support breakpoints download, hope you can help me analyze, be grateful.

code:

#import "DownLoadViewController.h"
#import "BaseCell.h"
#import <AFNetworking.h>
#import "DownModel.h"

#define fileDest [NSHomeDirectory() stringByAppendingPathComponent:@"Documents/"]

NSString * const kMZDownloadKeyURL = @"URL";
NSString * const kMZDownloadKeyStartTime = @"startTime";
NSString * const kMZDownloadKeyFileName = @"fileName";
NSString * const kMZDownloadKeyProgress = @"progress";
NSString * const kMZDownloadKeyTask = @"downloadTask";
NSString * const kMZDownloadKeyStatus = @"requestStatus";
NSString * const kMZDownloadKeyDetails = @"downloadDetails";
NSString * const kMZDownloadKeyResumeData = @"resumedata";

NSString * const RequestStatusDownloading = @"RequestStatusDownloading";
NSString * const RequestStatusPaused = @"RequestStatusPaused";
NSString * const RequestStatusFailed = @"RequestStatusFailed";

@interface DownLoadViewController ()<UITableViewDataSource,UITableViewDelegate,NSURLSessionDelegate,NSURLSessionTaskDelegate,NSURLSessionDownloadDelegate,NSURLSessionDataDelegate>
{
    UITableView *mainTable;
    NSMutableArray *tableData;

    /** 保存所有下载信息的数组 */
    NSMutableArray *downloadingArray;
}

@end

@implementation DownLoadViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    self.view.backgroundColor = [UIColor whiteColor];
    self.title = @"视频下载";

    mainTable = [[UITableView alloc] initWithFrame:self.view.bounds style:UITableViewStyleGrouped];
    mainTable.delegate = self;
    mainTable.dataSource = self;
    [self.view addSubview:mainTable];

    tableData = [NSMutableArray array];

    downloadingArray = [NSMutableArray array];

     /** 请求下载列表 */
    [self requestData];
}

/**
 *  请求数据
 */
- (void)requestData
{
    AFHTTPRequestOperationManager *manager = [AFHTTPRequestOperationManager manager];
    manager.requestSerializer = [AFJSONRequestSerializer serializer];
    manager.responseSerializer = [AFJSONResponseSerializer serializer];
    manager.responseSerializer.acceptableContentTypes = [NSSet setWithObjects:@"application/json", @"text/json", @"text/javascript",@"text/plain", @"text/html", nil];

    [manager GET:@"http://ac.ybjk.com/vod_v1.php?km=km3&m=sp" parameters:nil success:^(AFHTTPRequestOperation *operation, id responseObject) {

        NSMutableDictionary *resultDic = (NSMutableDictionary *)responseObject;

        NSArray *array = resultDic[@"data"];

        for (NSDictionary *dic in array)
        {
            DownModel *model = [[DownModel alloc] init];
            model.name = dic[@"title"];
            model.url = dic[@"url"];

            [tableData addObject:model];
        }

        /** 保存所有下载任务信息数组 初始化*/
        for (int i = 0 ; i < tableData.count ; i++)
        {
            NSMutableDictionary *tmpDic = [NSMutableDictionary dictionary];
            [downloadingArray addObject:tmpDic];
        }

        NSLog(@"所有下载任务信息 长度  %lu",(unsigned long)downloadingArray.count);

        [mainTable reloadData];

    } failure:^(AFHTTPRequestOperation *operation, NSError *error) {
        NSLog(@"请求失败");
    }];
}


- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
{
    return 1;
}

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
    return tableData.count;
}

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
    NSString *cellId = [NSString stringWithFormat:@"%ld%ld",(long)indexPath.section,(long)indexPath.row];
    BaseCell *cell = (BaseCell *)[tableView dequeueReusableCellWithIdentifier:cellId];
    if (!cell)
    {
        cell = [[BaseCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:cellId];
        cell.selectionStyle = UITableViewCellSelectionStyleNone;
    }

    DownModel *model = [tableData objectAtIndex:indexPath.row];

    cell.nameLabel.text = model.name;
    cell.downBtn.tag = indexPath.row;
    [cell.downBtn addTarget:self action:@selector(downBtnAction:) forControlEvents:UIControlEventTouchUpInside];

    NSString *fileName = [NSString stringWithFormat:@"%@.mp4",model.name];

    // 2. 生成沙盒的路径
    NSArray *docs = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
    NSString *path = [docs[0] stringByAppendingPathComponent:fileName];

    if ([[NSFileManager defaultManager] fileExistsAtPath:path])
    {
        /** 如果文件存在 */
        cell.downBtn.hidden = YES;
        cell.sizeLabel.text = @"已下载至本地";
    }

    return cell;
}

- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
{
    return 60.0f;
}

- (CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section
{
    return 15.0f;
}

- (CGFloat)tableView:(UITableView *)tableView heightForFooterInSection:(NSInteger)section
{
    return 0.1f;
}

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
    [tableView deselectRowAtIndexPath:indexPath animated:YES];
}

/**
 *  刷新选中cell
 *
 *  @param cell      cell
 *  @param indexPath 选中行数
 */
- (void)updateCell:(BaseCell *)cell forRowAtIndexPath:(NSIndexPath *)indexPath
{
    NSMutableDictionary *downloadInfoDict = [downloadingArray objectAtIndex:indexPath.row];

     /** 文件名称 */
    NSString *fileName = [downloadInfoDict objectForKey:kMZDownloadKeyFileName];
    cell.nameLabel.text = fileName;
     /** 文件大小 */
    [cell.detailTextLabel setText:[downloadInfoDict objectForKey:kMZDownloadKeyDetails]];
     /** 下载进度 */
    [cell.progressView setProgress:[[downloadInfoDict objectForKey:kMZDownloadKeyProgress] floatValue]];
}

#pragma mark -  下载事件
- (void)downBtnAction:(UIButton *)btn
{
     /** 获得当前操作行数 */
    NSIndexPath *path = [NSIndexPath indexPathForRow:btn.tag inSection:0];
    BaseCell *cell = (BaseCell *)[mainTable cellForRowAtIndexPath:path];

     /** 获得当前操作行数对象 */
    DownModel *model = [tableData objectAtIndex:btn.tag];
     /** 下载的文件名称 */
    NSString *fileName = model.name;
     /** 下载的url */
    NSString *fileURL = model.url;

    if (!btn.selected)
    {
        NSLog(@"开始下载");
        [btn setSelected:YES];

        /** 获得当前操作行数 下载任务信息 */
        NSMutableDictionary *downloadInfo = [downloadingArray objectAtIndex:path.row];
        /** 获得当前操作行数 下载任务 */
        NSURLSessionDownloadTask *downloadTask = [downloadInfo objectForKey:kMZDownloadKeyTask];

        if (downloadTask)
        {
            /** 执行断点下载 */

            NSData *resumeData = [[downloadInfo objectForKey:kMZDownloadKeyResumeData] dataUsingEncoding:NSUTF8StringEncoding];
            downloadTask = [self.sessionManager downloadTaskWithResumeData:resumeData];
            [downloadTask resume];
        }
        else
        {
            /** 添加下载任务 */
            [self addDownloadTask:fileName fileURL:fileURL indexRow:btn.tag];
        }




    }
    else
    {
        NSLog(@"暂停下载");
        [btn setSelected:NO];

         /** 获得当前操作行数 下载任务信息 */
        NSMutableDictionary *downloadInfo = [downloadingArray objectAtIndex:path.row];
         /** 获得当前操作行数 下载任务 */
        NSURLSessionDownloadTask *downloadTask = [downloadInfo objectForKey:kMZDownloadKeyTask];
         /** 获得当前操作行数 下载状态 */
        NSString *downloadStatus = [downloadInfo objectForKey:kMZDownloadKeyStatus];

        if ([downloadStatus isEqualToString:RequestStatusDownloading])
        {
             /** 当前状态为正在下载,则暂停下载 */
//            [downloadTask suspend]; /** 暂停下载 */
//            [downloadTask cancel];
             /** 断点下载,保存断点data */
            [downloadTask cancelByProducingResumeData:^(NSData *resumeData) {

                NSString *dataString = [[NSString alloc] initWithData:resumeData encoding:NSUTF8StringEncoding];
                NSLog(@"断点数据 %@",dataString);
                [downloadInfo setObject:dataString forKey:kMZDownloadKeyResumeData];
            }];

            [downloadInfo setObject:RequestStatusPaused forKey:kMZDownloadKeyStatus]; /** 设置下载任务信息为暂停状态 */
             /** 更新下载任务数组中  当前任务信息 */
            [downloadingArray replaceObjectAtIndex:path.row withObject:downloadInfo];

             /** 刷新 当前 选中 cell */
            [self updateCell:cell forRowAtIndexPath:path];
        }
    }
}

#pragma mark -  懒加载 获得session
- (NSURLSession *)sessionManager
{
    static NSURLSession *session = nil;
    static dispatch_once_t onceToken;
    dispatch_once(&onceToken, ^{
        session = [NSURLSession sessionWithConfiguration:[NSURLSessionConfiguration defaultSessionConfiguration] delegate:self delegateQueue:nil];
    });
    return session;
}

/**
 *  添加下载任务
 *
 *  @param fileName 文件名
 *  @param fileURL  文件URL
 */
- (void)addDownloadTask:(NSString *)fileName fileURL:(NSString *)fileURL indexRow:(NSInteger)indexRow
{
     /** 初始化下载任务 */
    NSURL *url = [NSURL URLWithString:fileURL];
    NSURLRequest *request = [NSURLRequest requestWithURL:url];
    NSURLSessionDownloadTask *downloadTask = [self.sessionManager downloadTaskWithRequest:request];

     /** 启动下载任务 */
    [downloadTask resume];

     /** 保存本次下载任务信息 */
    NSMutableDictionary *downloadInfo = [NSMutableDictionary dictionary];
    [downloadInfo setObject:fileURL forKey:kMZDownloadKeyURL]; /** 下载url */
    [downloadInfo setObject:fileName forKey:kMZDownloadKeyFileName]; /** 下载文件名称 */

     /** 将保存任务信息的字典转化为json字符串,设置本次下载任务的描述 */
    NSError *error = nil;
    NSData *jsonData = [NSJSONSerialization dataWithJSONObject:downloadInfo options:NSJSONWritingPrettyPrinted error:&error];
    NSString *jsonString = [[NSString alloc] initWithData:jsonData encoding:NSUTF8StringEncoding];
    downloadTask.taskDescription = jsonString;

     /** 继续向字典中添加本次下载任务信息 */
    [downloadInfo setObject:RequestStatusDownloading forKey:kMZDownloadKeyStatus]; /** 下载状态  (正在下载,暂停下载,下载失败)  */
    [downloadInfo setObject:downloadTask forKey:kMZDownloadKeyTask]; /** 本次下载任务 */

     /** 将本次下载任务信息保存到数组中 */
//    [downloadingArray addObject:downloadInfo];
    [downloadingArray replaceObjectAtIndex:indexRow withObject:downloadInfo];
}


#pragma mark -  NSURLSession Delegate
- (void)URLSession:(NSURLSession *)session downloadTask:(NSURLSessionDownloadTask *)downloadTask didWriteData:(int64_t)bytesWritten totalBytesWritten:(int64_t)totalBytesWritten totalBytesExpectedToWrite:(int64_t)totalBytesExpectedToWrite
{
     /** 遍历下载任务信息数组,获得每一个下载任务信息 */
    for (NSMutableDictionary *downloadDict in downloadingArray)
    {

         /** 获得当前所有下载任务中 与 代理方法中的 downloadTask 一致的 */
        if ([downloadTask isEqual:[downloadDict objectForKey:kMZDownloadKeyTask]])
        {
            dispatch_async(dispatch_get_main_queue(), ^{
                /** 回到主线程,渲染UI */
                float progress = (double)downloadTask.countOfBytesReceived/(double)downloadTask.countOfBytesExpectedToReceive;

                /** 获取当前任务所在cell */
                NSInteger indexOfDownloadDict = [downloadingArray indexOfObject:downloadDict];
                NSIndexPath *indexPathToRefresh = [NSIndexPath indexPathForRow:indexOfDownloadDict inSection:0];
                BaseCell *cell = (BaseCell *)[mainTable cellForRowAtIndexPath:indexPathToRefresh];

                /** 进度条 */
                cell.progressView.progress = progress;

                /** 文件大小 */
                cell.sizeLabel.text = [NSString stringWithFormat:@"%.2fM/%.2fM",(CGFloat)totalBytesWritten/1024/1024,(CGFloat)totalBytesExpectedToWrite/1024/1024];

                /** 保存当前下载任务的进度 以及 文件大小信息 */
                [downloadDict setObject:[NSString stringWithFormat:@"%f",progress] forKey:kMZDownloadKeyProgress]; /** 保存进度 */
                [downloadDict setObject:cell.sizeLabel.text forKey:kMZDownloadKeyDetails]; /** 文件大小 */
            });

            break;
        }
    }
}

- (void)URLSession:(NSURLSession *)session downloadTask:(NSURLSessionDownloadTask *)downloadTask didFinishDownloadingToURL:(NSURL *)location
{
    /** 遍历下载任务信息数组,获得每一个下载任务信息 */
    for (NSMutableDictionary *downloadDict in downloadingArray)
    {
        /** 获得当前所有下载任务中 与 代理方法中的 downloadTask 一致的 */
        if ([downloadTask isEqual:[downloadDict objectForKey:kMZDownloadKeyTask]])
        {
             /** 保存的文件名 */
            NSString *fileName = [downloadDict objectForKey:kMZDownloadKeyFileName];
             /** 保存路径 */
            NSString *savePath = [fileDest stringByAppendingPathComponent:fileName];
            NSURL *fileURL = [NSURL fileURLWithPath:savePath];
            NSLog(@"下载文件保存路径: %@",savePath);

             /** 将下载好的文件从临时文件夹中保存到指定路径 */
            if (location)
            {
                NSError *error = nil;
                [[NSFileManager defaultManager] moveItemAtURL:location toURL:fileURL error:&error];
                if (error)
                {
                    UIAlertView *alert = [[UIAlertView alloc] initWithTitle:nil message:error.localizedDescription delegate:self cancelButtonTitle:@"OK" otherButtonTitles:nil, nil];
                    [alert show];
                }
            }

            break;
        }
    }
}

- (void)URLSession:(NSURLSession *)session task:(NSURLSessionTask *)task didCompleteWithError:(NSError *)error
{
    NSLog(@"error %@",error.localizedDescription);

    NSLog(@"===== %@",[error.userInfo objectForKey:NSURLSessionDownloadTaskResumeData]);
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

Error when I try to run Example code

I got this error when I try to run Example code

/Library/Developer/Xcode/DerivedData/MZDownloadManager-dxfnwszyostjnphejzzptzotboct/Build/Products/Debug-iphonesimulator/MZDownloadManager.bundle: bundle format unrecognized, invalid, or unsuitable
Command /usr/bin/codesign failed with exit code 1

Download failed message / delegate?

I wanted to check and see if for some reason download failed or if the link was bad to begin with, how can I catch that and tell the user that file cannot be downloaded.

for example in the files I changed the first file path to http://dl.dropbox.com/u/97700329/100_file1.mp4
When I click on the download I get no errors. How can I add an error message? I did not see any failure delegate method.

OC version

is there any OC version for MZDownloadManager ?thx

Two Simultaneous Download Tasks Results in Crash

There seems to be an array index out of bounds error at line 222 in MZDownloadManager.swift here:

self.downloadingArray[index] = downloadModel

It seems that when the first download completes, it is removed from the downloadingArray, but the second download's index does not change from 1 to 0. We could resolve this by changing downloadingArray to a dictionary, and changing the downloadModel's index to some randomly generated string. Thoughts?

Invalid URL scheme for background downloads: (null). Valid schemes are http or https

When call

  • (void)addDownloadTask:(NSString *)fileName fileURL:(NSString *)fileURL

if fileURL contain white space in filename so

we have: Invalid URL scheme for background downloads: (null). Valid schemes are http or https

Please replace this line

NSURL *url = [NSURL URLWithString:fileURL];

whith:

NSURL *url = [NSURL URLWithString:
[[fileURL stringByAddingPercentEscapesUsingEncoding: NSUTF8StringEncoding]
stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceAndNewlineCharacterSet]]];

Get crushed with error message setObjectForKey: object cannot be nil (key: downloadTask)

I am using this class for downloading of more than 100 PDFs at a time by using addtask delegate method of MZDownloadManager , But after 2-3 times of exceution its getting below error and my app goes to be crushed
* Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '* setObjectForKey: object cannot be nil (key: downloadTask)'

and for low number of PDFs its working fine , can you please suggest the solution ?
I hav tried with dispatch_queus but its not working

timeoutIntervalForRequest does not work

I have set timeoutIntervalForRequest in the session configuration and tried with a URL that gives a timeout "http://www.google.com:81/" but the timeout is not triggered, didFinishWithError is not called. On the contrary if i ser timeoutIntervalForResponse this timeout is triggered. Maybe you have some insight?

Making Downloads stay until dismissed

You should make it so the downloads stay on the list, even if user closes app fully and reopens that all downloads stay on the list until the user deletes them.

App rejected by Apple when using this component and copying to documents directory

If we use this control to download files, and save to document directory, Apple rejects it because the downloaded data is by default synced to iCloud.

Please add the below code in addDownloadTask method to set NSURLIsExcludedFromBackupKey so files are not automatically synced to iCloud and Apple accepts it :).

  • (void)addDownloadTask:(NSString *)fileName fileURL:(NSString *)fileURL
    {
    NSURL *url = [NSURL URLWithString:fileURL];
    [url setResourceValue:@(YES) forKey:NSURLIsExcludedFromBackupKey error:nil];
    ...
    ...

code sign in error

downloaded the project unable to run its show code sign in error i am using xcode 8

Index out of range

Hello

Trying to download 2 objects at the same time, an out of range exception is thrown caused by this line : 208 :
self.downloadingArray[index] = downloadModel

file : MZDownloadManager.swift

look likes a race condition, since the object may be removed befor the code above is executed, which lead to that exception.

to fix this issue, I changed to previous line with the following :

 if self.downloadingArray.contains(downloadModel), let objectIndex = self.downloadingArray.index(of: downloadModel) {

                        self.downloadingArray[objectIndex] = downloadModel

                    }

Background download issues

Hello. I'm using MZDownloadManager to perform around 500 downloads in my app. I'd like to be able to let the user exit the app during the downloads, but I'm not sure how to do it. I'm able to make this work on the Simulator without any specific setting, but not on the real device. I've set up the Background Modes capabilities for my target. Do you have any suggestion?

download not resume

download not resume when app force quit.
Because when app force quit then - (void)URLSession:(NSURLSession *)session task(NSURLSessionTask *)task didCompleteWithError:(NSError *)error;
method not called which save data for resume.
Please help how to resume .

Tracking the progress of the Download from downloadingArray

Hi
First of all, thanks for giving such wonderful library. I have started a download in a view controller, then close the view controller, my logic is when

When I come back to that view controller, then I want to show the progress of the downloding (Keeping in mind, I am recreating the view controller)

Now, I am able to get the downloading array from the singleton variable that is downloadManager

so, my code is like this

var arry = self.downloadManager.downloadingArray
for index:Int in 0 ..< arry.count {
var model = arry[index]

        if let mo = self.movieURL {
        let url = URL(string: self.movieURL)
        if model.fileName! == url?.lastPathComponent{                
            if let button = self.downloadButton{
            // I am trying to get the ongroing progress here however, I am getting 0 here
            }
        }
        }
    }

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.