File tree 2 files changed +25
-0
lines changed
2 files changed +25
-0
lines changed Original file line number Diff line number Diff line change @@ -192,6 +192,16 @@ extern float const SSYProgressPriorityRegular;
192
192
*/
193
193
- (void )incrementDoubleValueBy : (double )value ;
194
194
195
+ /* !
196
+ @brief Sets the receiver to show a progress bar, increments
197
+ its doubleValue (the progress value) by a given value, and runs the
198
+ main run loop.
199
+
200
+ @details This is useful if you want the receiver's view to update
201
+ before long-running operations continue on the main therad.
202
+ */
203
+ - (void )incrementAndRunDoubleValueBy : (double )value ;
204
+
195
205
/* !
196
206
@brief Sets the receiver to show a progress bar, and increments
197
207
its doubleValue (the progress value) by a given value wrapped in
Original file line number Diff line number Diff line change @@ -1007,6 +1007,21 @@ - (void)incrementDoubleValueBy:(double)delta {
1007
1007
[self setDoubleValue: newProgressValue] ;
1008
1008
}
1009
1009
1010
+ - (void )incrementAndRunDoubleValueBy : (double )delta {
1011
+ double newProgressValue = [self progressValue ] + delta ;
1012
+ [self setProgressValue: newProgressValue] ;
1013
+ NSTimeInterval secondsNow = [NSDate timeIntervalSinceReferenceDate ] ;
1014
+ if (secondsNow > [self nextProgressUpdate ]) {
1015
+ [self setNextProgressUpdate: (secondsNow + PROGRESS_UPDATE_PERIOD)] ;
1016
+ [NSInvocation invokeOnMainThreadTarget: self
1017
+ selector: @selector (unsafeSetDoubleValue: )
1018
+ retainArguments: YES
1019
+ waitUntilDone: YES
1020
+ argumentAddresses: &newProgressValue] ;
1021
+ [[NSRunLoop mainRunLoop ] runUntilDate: [NSDate date ]];
1022
+ }
1023
+ }
1024
+
1010
1025
- (void )incrementDoubleValueByObject : (NSNumber *)value {
1011
1026
[self incrementDoubleValueBy: [value doubleValue ]] ;
1012
1027
}
You can’t perform that action at this time.
0 commit comments