Sara Canducci Sara Canducci - 3 months ago 7
Swift Question

Convert code from Objective-C to Swift

I've got this line of code in Objective-C and I absolutely need to "translate it" to Swift.

BOOL hasBlur = blurRadius > __FLT_EPSILON__


Unfortunately I get this error:


Use of unresolved identifier __FLT_EPSILON_


Can you help me?
Thanks

Answer

__FLT_EPSILON__ is a predefined macro of the compiler, apparently not available in Swift. But <float.h> defines

#define FLT_EPSILON __FLT_EPSILON__

and this is available in Swift as well:

let hasBlur = blurRadius > FLT_EPSILON