dispatch_after macro misleading
| Originator: | rjo218 | ||
| Number: | rdar://12758127 | Date Originated: | 27-Nov-2012 11:32 AM |
| Status: | Closed | Resolved: | |
| Product: | GCD | Product Version: | |
| Classification: | enhancement | Reproducible: |
The GCD dispatch_after macro comes up as:
int64_t delayInSeconds = 2.0;
dispatch_time_t popTime = dispatch_time(DISPATCH_TIME_NOW, delayInSeconds * NSEC_PER_SEC);
dispatch_after(popTime, dispatch_get_main_queue(), ^(void){
//code
});
when it would make more sense to make it something like:
double delayInSeconds = 2.0f;
int64_t delayInNsecs = delayInSeconds * NSEC_PER_SEC;
dispatch_time_t popTime = dispatch_time(DISPATCH_TIME_NOW, delayInNsecs);
dispatch_after(popTime, dispatch_get_main_queue(), ^(void){
//code
});
to account for the float value implied in the first line.
Comments
Please note: Reports posted here will not necessarily be seen by Apple. All problems should be submitted at bugreport.apple.com before they are posted here. Please only post information for Radars that you have filed yourself, and please do not include Apple confidential information in your posts. Thank you!