forum

Home / DeveloperSection / Forums / How to cast id into a float?

How to cast id into a float?

Tarun Kumar159122-Sep-2015

I write a code and getting problem with this code:

NSRect myFrame;

id item;

// for assigning code to item

myFrame.origin.y -= [item respondsToSelector:@selector(myHeight)] ? [item myHeight]   : [self defaultMyHeight];

Here is the problem:

[item myHeight]

The compiler is assuming that the return type is id. So, I thought that by using type cast I would fix this:

(float)[item myHeight]

 

but it’s not working.

So, I’m not understanding that what amoing wrong.oing wrong. I doing wrong.


Updated on 23-Sep-2015

Can you answer this question?


Answer

1 Answers

Liked By