12207480 / TYDownloadManager

Download file manager wrapped NSURLSessionDataTask and NSURLSessionDownloadTask,provide progress update and status change.
409 stars 79 forks source link

Pull Request #48 中问题的简单解法 #53

Open yehot opened 6 years ago

yehot commented 6 years ago

Pull Request #48 中提到的问题,以下是一个更简单解法

// TYDownloadModel.m 

- (instancetype)initWithURLString:(NSString *)URLString
                         filePath:(NSString *)filePath {
    if (self = [self init]) {
        _downloadURL = URLString;

        // to fix url 中有 query 参数,导致取到的 file name 为 xxx.mp3?xxxx 的问题
        _fileName = [NSURL URLWithString:URLString].lastPathComponent;

        _downloadDirectory = filePath.stringByDeletingLastPathComponent;
        _filePath = filePath;
    }
    return self;
}