tags:

views:

33

answers:

2

I'm pretty new to iPhone programming, so I'm looking for any pointers (no pun intended), links, search terms, etc. on how to make a very simple app that counts how many times one finger touches the screen and how long between each tap.

Thanks for any help, I know this resembles a lame question seeing as how I have really accomplished anything yet.

rd42

+1  A: 

You'll want to use touchesBegan: and touchesEnded: methods of UIResponder.

All UIViews are UIResponders. So just override those methods on whatever UIView you want the users to touch. Note that there are four touches methods:

touchesBegan:
touchesMoved:
touchesEnded:
touchesCancelled:

If you override any of them, you are required to override all of them. So for the ones you don't care about, just have practically-empty implementations that just call [super touchesMoved: arg1 withEvent: arg2], etc.

Jon Rodriguez
+3  A: 

In touchesBegan, use:

NSSet *allTouches = [event allTouches];
int tapCount = [allTouches count];

to retrieve the tap count.

You would then need to save the timestamp of the first tap, and find the difference between the next tap in order to get the time elapsed between them.

Evan Mulawski
rd42