views:

34

answers:

2

I need to find the specific time a tap happens and then the time since it has passed. I have the app counting taps, I just haven't figured out the time thing.

I tried:

timeStamp = [[NSDate date] timeIntervalSince1970]; 

but I'm new to obj c and clearly there is a syntax problem.

Thanks for anyhelp.

A: 

The most obvious reason I see for a syntax error would be the declaration of timeStamp.

It should be:

NSTimeInterval timeStamp;
mouviciel
+2  A: 

If you are trying to find the amount of time that has passed since an event, I would create an NSDate time stamp when that event occurrs:

NSDate *timestamp = [NSDate date];

Then, later on to check how long it has been since that timestamp you can call:

NSTimeInterval interval = [timestamp timeIntervalSinceNow];

NSTimeInterval is just a typedef. It is actually a double representing a number of seconds. In the above case interval will be the number of seconds since the timestamp. (Also note that it will be negative since your timestamp is in the past.)

Tim Isganitis