Caps-iOS/Caps/Download/ClassifierProgressObserver.swift
2025-01-31 14:52:20 +01:00

21 lines
671 B
Swift

import Foundation
final class ClassifierProgressObserver: NSObject {
weak var delegate: ClassifierProgressDelegate?
}
extension ClassifierProgressObserver: URLSessionDownloadDelegate {
func urlSession(_ session: URLSession, downloadTask: URLSessionDownloadTask, didFinishDownloadingTo location: URL) {
}
func urlSession(_ session: URLSession, downloadTask: URLSessionDownloadTask, didWriteData bytesWritten: Int64, totalBytesWritten: Int64, totalBytesExpectedToWrite: Int64) {
delegate?.classifierProgress(.init(
bytesLoaded: Double(totalBytesWritten),
total: Double(totalBytesExpectedToWrite)))
}
}