MBCoverFlowView
MBCoverFlowView copied to clipboard
fmax use in MBCoverFlow
There is a subtle bug in this line:
[_scroller setNumberOfIncrements:fmax([self.content count]-1, 0)];
Namely, the count method returns an unsigned long (NSUInteger), and therefore when count is 0, and you subtract 1, you get an overflow. This can be fixed easily enough by casting to a signed integer:
[_scroller setNumberOfIncrements:fmax(((NSInteger)[self.content count])-1, 0)];
And yes, nine years on I am still using this code in Keyboard Maestro.