diff --git a/Sources/MZDownloadManager/Classes/MZDownloadManager.swift b/Sources/MZDownloadManager/Classes/MZDownloadManager.swift index e50d846..db6d975 100644 --- a/Sources/MZDownloadManager/Classes/MZDownloadManager.swift +++ b/Sources/MZDownloadManager/Classes/MZDownloadManager.swift @@ -64,7 +64,7 @@ fileprivate func > (lhs: T?, rhs: T?) -> Bool { open class MZDownloadManager: NSObject { - fileprivate var sessionManager: URLSession! + public var sessionManager: URLSession! fileprivate var backgroundSessionCompletionHandler: (() -> Void)? @@ -72,7 +72,7 @@ open class MZDownloadManager: NSObject { fileprivate let TaskDescFileURLIndex = 1 fileprivate let TaskDescFileDestinationIndex = 2 - fileprivate weak var delegate: MZDownloadManagerDelegate? + public weak var delegate: MZDownloadManagerDelegate? open var downloadingArray: [MZDownloadModel] = [] @@ -287,6 +287,7 @@ extension MZDownloadManager: URLSessionDownloadDelegate { self.downloadingArray.remove(at: index) if err == nil { + downloadModel.finished?() self.delegate?.downloadRequestFinished?(downloadModel, index: index) } else { self.delegate?.downloadRequestCanceled?(downloadModel, index: index) diff --git a/Sources/MZDownloadManager/Classes/MZDownloadModel.swift b/Sources/MZDownloadManager/Classes/MZDownloadModel.swift index fd82170..cd6a49b 100644 --- a/Sources/MZDownloadManager/Classes/MZDownloadModel.swift +++ b/Sources/MZDownloadManager/Classes/MZDownloadModel.swift @@ -46,6 +46,8 @@ open class MZDownloadModel: NSObject { open var startTime: Date? + open var finished: (() -> Void)? + fileprivate(set) open var destinationPath: String = "" fileprivate convenience init(fileName: String, fileURL: String) { @@ -55,7 +57,7 @@ open class MZDownloadModel: NSObject { self.fileURL = fileURL } - convenience init(fileName: String, fileURL: String, destinationPath: String) { + public convenience init(fileName: String, fileURL: String, destinationPath: String) { self.init(fileName: fileName, fileURL: fileURL) self.destinationPath = destinationPath