Convert int to CGFloat

integer, iphone, objective-c

Solution

In the past casting a CGFloat value using the () syntax has worked fine for me. CGFloat is just defined as "typedef float CGFloat;" so you go about casting it the same way you would a float:

CGFloat f = (CGFloat)intVal;

or, if your value is a constant:

CGFloat f = 1.10;

Problem

Any idea on how to convert an `int` to `CGFloat` in Objective-C?

Original source