[Solved] Confused about ios touches code [duplicate]


UITouch *touch = [touches anyObject];

touches is a NSSet of UITouch. The code simply gets one object from touches and assigns it to a variable named touch. This is implicitly assuming that the NSSet hold only one element.

CGPoint location = [touch locationInView:[touch view]];

the above line gets the (x,y) coordinates of the touch in the coordinate system of the view that intercepted the touch. CGPoint is nothing more than a C struct with two float values, x and y.

So bottom line you will obtain the coordinates of the touch in the view.

solved Confused about ios touches code [duplicate]