There is no documentation for Progress.estimatedTimeRemaining. I want to get an estimated time to completion from my Progress object, but in my experiments on macOS, it's always nil. What do I need to do to get a non-nil result?
In my case, my progress var is periodically (once per second) updated from the var progress:Float field of a AVAssetExportSession.
Here's what I've got now that's not working: (the progressIndicator is correctly updating)
@IBOutlet weak var timeRemainingLabel:NSTextField?
lazy var nsProgress:Progress = { ()->Progress in
let prog = Progress(totalUnitCount: 100)
return prog
}()
var progress:Float = 0.0 {
didSet {
progressIndicator?.doubleValue = Double(progress)
nsProgress.completedUnitCount = Int64((progress*100.0).rounded())
if let time = nsProgress.estimatedTimeRemaining {
timeRemainingLabel?.stringValue = timeFormatter.string(from: time) ?? ""
}
}
}
lazy var timeFormatter:DateComponentsFormatter = SongTitledFormSectionsTableCell.newDurationFormatter()
static func newDurationFormatter()->DateComponentsFormatter {
let formatter = DateComponentsFormatter()
formatter.allowedUnits = [.second, .minute]
return formatter
}