Quick tip: Convert float to int in Swift

It is a new language, ok. But why people can complex simple things? For years we used:

and it was ok. Not only in ObjectiveC but in many other. Now you have to:

BUT – keep in mind that float will be always ROUNDED DOWN – so for 1.9 you will get 1 not 2. To make it rounded as it should be use:

 

Leave a Reply