The following Swift code fails to compile and I simply don't see what's the problem:
while fabsf(newPercentage - percentage) < 0.006 {
newPercentage = ((CGFloat)(arc4random() % 220) - 110) * 0.0001;
}
The first line has the following compilation error message: Cannot invoke '<' with an argument list of type '(Float, FloatLiteralConvertible)'
But I don't understand since fabsf returns a Float, and my constant is a Float.
For future reference, here is the Objective-C code I'm trying to translate to Swift:
CGFloat percentage = 0.0f;
for (NSInteger i = 0; i < RotationCount; i++) {
// ensure that each angle is different enough to be seen
CGFloat newPercentage = 0.0f;
do {
newPercentage = ((CGFloat)(arc4random() % 220) - 110) * 0.0001f;
} while (fabsf(percentage - newPercentage) < 0.006);
percentage = newPercentage;
CGFloat angle = 2 * M_PI * (1.0f + percentage);
CATransform3D transform = CATransform3DMakeRotation(angle, 0.0f, 0.0f, 1.0f);
[rotations addObject:[NSValue valueWithCATransform3D:transform]];
}