Reputation: 77
The .loadTransferable method returns a progress object (https://developer.apple.com/documentation/photokit/photospickeritem/4030160-loadtransferable)
It seems the progress class returned from the loadTransferable method does not update properly. In the below example, I've added a timer to observe the progress object since KVO doesn't fire, and it's unchanging
private func onSelection() {
guard let item = self.selection else {
return
}
self.progress = item.loadTransferable(type: Data.self) { result in
/// ...
}
self.observeProgress()
}
private func observeProgress() {
guard let progress = self.progress else { return }
let _ = Timer.scheduledTimer(withTimeInterval: 0.1, repeats: true) { timer in
print(progress)
if progress.isFinished {
timer.invalidate()
}
}
}
Logs:
<NSProgress: 0x600002c2d300> : Parent: 0x0 (portion: 0) / Fraction completed: 0.0000 / Completed: 0 of 0
The above log repeated as the timer fires
Upvotes: 2
Views: 134