[swift-evolution] Pitch: Progress Tracking in Swift
cocoadev at charlessoft.com
cocoadev at charlessoft.com
Mon Jan 18 18:32:22 CST 2016
While that's true, it hearkens back to those obnoxious NSError **
parameters that had to be put on the end of every last method in
ObjC/Cocoa. The Swift do/try/catch mechanism is much nicer, and I was
hoping to do something more along those lines. Besides, passing around a
single progress would lose NSProgress's greatest feature, which is the
tree of progress objects, each of which tracks the progress of a single
function or method.
Charles
On 2016-01-18 12:26, Will Entriken wrote:
> Charles,
>
> I think this is interesting. And discussion on replacing/updating
> NSProgress is important.
>
> Just a note: optional parameters make this possible without changing
> the language. A very rough example follows:
>
> func delete(files: FileList, withProgress progress: Progress? = nil) {
> progress.totalUnits = 10
> print("Getting started")
> progress.completedUnits = 5 // that was easy!
> actuallyDelete(files, withProgress: progress.childWithUnits: 5)
> }
>
> let progress = Progress()
> // watch progress.totalPortion using KVO 2.0
> delete(files: allTheFiles, withProgress: progress)
>
> Regards,
> Will
>
> On Sun, Jan 17, 2016 at 9:42 PM, Charles Srstka via swift-evolution
> <swift-evolution at swift.org> wrote:
>
>> Typo here: This should have said "on the current thread." The fact
>> that NSProgress bogs down the worker thread with the work involved
>> in creating the KVO notifications is part of my issue with it.
>>
>> Charles
>>
>> On 2016-01-17 21:14, Charles Srstka via swift-evolution wrote:
>>
>>> 5. NSProgress posts KVO notifications on the main thread.
>>
>> _______________________________________________
>> swift-evolution mailing list
>> swift-evolution at swift.org
>> https://lists.swift.org/mailman/listinfo/swift-evolution [1]
>
>
>
> Links:
> ------
> [1] https://lists.swift.org/mailman/listinfo/swift-evolution
More information about the swift-evolution
mailing list