-
Notifications
You must be signed in to change notification settings - Fork 1.2k
NSProgress #361
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
NSProgress #361
Conversation
First question for @parkera (or anybody else who can answer): are we allowed to make very small API modifications? For example, I was envisioning moving some string values into enums with raw value strings:
Would become:
Its more of a "namespacing" change really. |
For now, let's leave the API identical to the one in Foundation. That will make it easier to update in the future. You probably already noticed that the swift-evolution "drop NS" proposal listed this particular enum as being hoisted into the Progress class itself anyway. More details on that will be available a little bit later. |
@parkera Ok, sounds great. One extra question: Objective-C Foundation has EDIT: They were originally two questions, but I figure it out on my own ^^ |
@parkera New question :) The comments for isIndeterminate say:
But after unit-testing Darwin Foundation,
I guess I should follow the implementation rather than the documentation? |
I think I had to change the definition of
|
@@ -118,11 +137,21 @@ public class NSProgress : NSObject { | |||
|
|||
/* Whether the progress being made is indeterminate. -isIndeterminate returns YES when the value of the totalUnitCount or completedUnitCount property is less than zero. Zero values for both of those properties indicates that there turned out to not be any work to do after all; -isIndeterminate returns NO and -fractionCompleted returns 1.0 in that case. NSProgress is by default KVO-compliant for these properties, with the notifications always being sent on the thread which updates the property. | |||
*/ | |||
public var indeterminate: Bool { NSUnimplemented() } | |||
public var isIndeterminate: Bool { | |||
return completedUnitCount <= 0 && totalUnitCount <= 0 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
as described in the other comment:
completedUnitCount < 0 || totalUnitCount < 0 || (completedUnitCount == 0 && totalUnitCount == 0)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
by the way, isFinished is:
((_completed >= _total) && _completed > 0 && _total > 0) || (_completed > 0 && _total == 0);
This is a great start. |
# Conflicts: # Foundation.xcodeproj/project.pbxproj
@parkera I've taken up work on Is it OK to copy/paste some documentation from https://developer.apple.com/reference/foundation/nsprogress ? |
Other questions:
|
In fact, after more consideration, this is a weird case. Technically, if I want to be 100% compatible, I can't remove the IUO because the property's setter is public: I can set the |
The documentation is a bit misleading - these should never return an empty string. They are not really IOU, they are null-resettable. |
I've started working on NSProgress because it seems easy enough for me to implement. Here's what I've done so far:
completedUnitCount
,totalUnitCount
,fractionCompleted