Search code examples
objective-ccastingdrawrectcgrectmake

Convert float value to double in objective c


I have use the cast to convert a string to int, a string to double and it works.

Now I want to convert a float value to double and xcode tell me:

"Pointer cannot be cast to type 'double'",

My float variable is declared in .h

@property float *valueX, *valueY

And in .m I do:

double dou = (double) valorX;

What happen here? Thanks!


Solution

  • Not really sure what you're asking here but I imagine the problem is the * in the float properties.

    A float property should be declared as...

    @property float valueX;
    

    not

    @property float *valueX;
    

    (unless it's a pointer to a float but I doubt that's the case here)

    Note

    You probably should be doing something like this...

    @property (nonatomic, assign) CGFloat valueX;