I need to calculate the number of seconds that have passed between two events on the iPhone. To do so, I need to store the time that the first event occurred and check it against the time the second event occurred to see if more than 30 seconds has passed.
I'm about to begin trying to accomplish this using the NSDate class, but I was wondering if there's a simpler way to do this without using objects, as I would prefer to store simple, intrinsic values instead of objects.
Thanks for your wisdom!
If you really want to avoid storing objects, you can do something like:
double startTime = [[NSDate date] timeIntervalSince1970];
//Run your other code
double endTime = [[NSDate date] timeIntervalSince1970];
if (endTime - startTime > 30) {
//30 seconds have passed
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With