Simply if Statement for checking co-ordinate square.

Posted by JonB on Stack Overflow See other posts from Stack Overflow or by JonB
Published on 2010-03-20T19:54:29Z Indexed on 2010/03/20 20:01 UTC
Read the original article Hit count: 333

Filed under:
|
|

I have an UIImageView and taking the raw touch input. I need to check if a touch is within a certain set of squares. At the moment...

I have this if statement....

if(46 < touchedAt.x && touchedAt.x < 124 && 18 < touchedAt.y && touchedAt.y < 75)

but I have tried to simplify it to this one...

if(46 < touchedAt.x < 124 && 18 < touchedAt.y < 75)

It didn't work. Is it possible to simplify like this or am I stuck with the slightly lengthier version at the top? Is there a reason why the types of comparisons in the bottom if don't work?

Many Thanks.

© Stack Overflow or respective owner

Related posts about objective-c

Related posts about if-statement