Users Pricing

forum

home / developersection / forums / how to cast id into a float?

How to cast id into a float?

Tarun Kumar 1931 22 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.


Tarun Kumar

Other


1 Answers