Last active
October 5, 2016 18:52
-
-
Save 0xced/2c961f6d149143efd2f760b1e3bcd03a to your computer and use it in GitHub Desktop.
Demonstrates how NSProgress handlers being invoked on any queue (as documented) might be problematic
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#import <Foundation/Foundation.h> | |
int main(int argc, char *argv[]) | |
{ | |
@autoreleasepool | |
{ | |
NSProgress *progress = [[NSProgress alloc] initWithParent:nil userInfo:nil]; | |
progress.cancellationHandler = ^{ | |
NSLog(@"cancel"); | |
}; | |
progress.resumingHandler = ^{ | |
NSLog(@"resume"); | |
}; | |
for (int i = 0; i < 10; i++) | |
{ | |
NSLog(@"- %2d -", i); | |
[progress resume]; | |
[progress cancel]; | |
[progress resume]; | |
[progress cancel]; | |
NSLog(@"- %2d -", i); | |
} | |
dispatch_main(); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Sample output on El Capitan 10.11.6 (15G1004):
This behavior is documented, but welp.